<html>
<head><meta charset="utf-8"><title>Design of `AbortAlloc` not compatible with `try_reserve` · t-libs/wg-allocators · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/index.html">t-libs/wg-allocators</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html">Design of `AbortAlloc` not compatible with `try_reserve`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="181572440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/181572440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#181572440">(Nov 21 2019 at 18:54)</a>:</h4>
<p><code>AbortAlloc</code> is implemented as a wrapper around an arbitrary allocator <code>A</code>. <code>AbortAlloc</code> maps the returend error to <code>handle_alloc_error</code>. So if an OOM occures, there is no way to recover. Thus, <code>AbortAlloc</code> is incompatible with <code>try_reserve</code>. Any thoughts/idea on this?</p>



<a name="181599481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/181599481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Erich Gubler <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#181599481">(Nov 22 2019 at 00:28)</a>:</h4>
<p>What do you mean that it's incompatible?</p>



<a name="181613250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/181613250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#181613250">(Nov 22 2019 at 06:28)</a>:</h4>
<p>When calling <code>try_reserve</code> (or any other try_method), you expect to get an allocation error on OOM. <code>AbortAlloc</code> aborts before the function returns.</p>



<a name="181613265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/181613265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#181613265">(Nov 22 2019 at 06:28)</a>:</h4>
<p>This is the desired effect on methods like <code>reserve</code>, but not on <code>try_resersve</code>.</p>



<a name="182123371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182123371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182123371">(Nov 28 2019 at 17:01)</a>:</h4>
<p>Is <code>try_reserve</code> stable ?</p>



<a name="182123397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182123397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182123397">(Nov 28 2019 at 17:01)</a>:</h4>
<p>I think I would prefer to, e.g., get <code>try_</code> versions of all allocating methods, not only <code>reserve</code>, but all of them, by just using a <code>PanicAlloc</code> that panics, such that the panic can be caught</p>



<a name="182123410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182123410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182123410">(Nov 28 2019 at 17:01)</a>:</h4>
<p>I think it is stable</p>



<a name="182123411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182123411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182123411">(Nov 28 2019 at 17:02)</a>:</h4>
<p>The default allocator can <code>abort</code> on OOM</p>



<a name="182123456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182123456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182123456">(Nov 28 2019 at 17:02)</a>:</h4>
<p>*unstable</p>



<a name="182123465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182123465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182123465">(Nov 28 2019 at 17:02)</a>:</h4>
<p>I tried to prevent it from being stabilized for exactly this reason</p>



<a name="182123477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182123477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182123477">(Nov 28 2019 at 17:02)</a>:</h4>
<p>We can always deprecate it afterwards</p>



<a name="182124132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124132">(Nov 28 2019 at 17:12)</a>:</h4>
<p>One situation were this approach wouldn't work is if <code>-C panic=abort</code>.</p>



<a name="182124155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124155">(Nov 28 2019 at 17:13)</a>:</h4>
<p>In that case, <code>Vec::try_reserve</code> would still work properly, since no panics occur, but a <code>PanicOnOomAlloc&lt;MyAlloc&gt;</code> adapter would terminate the process.</p>



<a name="182124236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124236">(Nov 28 2019 at 17:14)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span>  in my PR, I used <code>repr(transparent)</code> so I could cast on and off the wrapper</p>



<a name="182124275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124275">(Nov 28 2019 at 17:15)</a>:</h4>
<p>So if you want today's <code>try_reserve</code>, you just cast away the <code>PanicOnOomAlloc&lt;_&gt;</code>, and then call <code>try_reserve</code>.</p>



<a name="182124338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124338">(Nov 28 2019 at 17:16)</a>:</h4>
<p>It's slightly more verbose but I don't really care. I think anyone that's using <code>try_reserve</code> today is much better off without <code>PanicOnOomAlloc</code> anyways.</p>



<a name="182124383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124383">(Nov 28 2019 at 17:17)</a>:</h4>
<p><code>try_reserve</code> is a hacky way to make the thing you actually want to do hopefully succeed. But that's racy; you still want to do not panic on the thing itself. And in that case unless you are reserving way before, you probably don't need the <code>try_reserve</code> at all.</p>



<a name="182124549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124549">(Nov 28 2019 at 17:20)</a>:</h4>
<blockquote>
<p>It's slightly more verbose but I don't really care. I think anyone that's using try_reserve today is much better off without PanicOnOomAlloc anyways.</p>
</blockquote>
<p><span class="user-mention" data-user-id="220594">@John Ericson</span> without or with ?</p>



<a name="182124572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124572">(Nov 28 2019 at 17:20)</a>:</h4>
<p>without</p>



<a name="182124589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124589">(Nov 28 2019 at 17:20)</a>:</h4>
<p>So you are in favour of only doing <code>try_reserve</code> ?</p>



<a name="182124593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124593">(Nov 28 2019 at 17:20)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> if you scroll up in that issue you posted in, you can read me describe the stuff I am saying here with more words</p>



<a name="182124599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124599">(Nov 28 2019 at 17:20)</a>:</h4>
<p>ok i will</p>



<a name="182124626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124626">(Nov 28 2019 at 17:21)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> I mean that <code>PanicOnOomAlloc</code> definitely should exist, but you shouldn't be mixing sometimes panicking and somtimes not panicking</p>



<a name="182124642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124642">(Nov 28 2019 at 17:21)</a>:</h4>
<blockquote>
<p>The default allocator can <code>abort</code> on OOM</p>
</blockquote>
<p>No, in today’s standard library it’s <code>Vec</code> and other callers that check for errors and call <code>handle_alloc_error</code> which in turn defaults to abort.</p>



<a name="182124750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124750">(Nov 28 2019 at 17:23)</a>:</h4>
<p><span class="user-mention" data-user-id="220594">@John Ericson</span> this one: <a href="https://github.com/rust-lang/rust/issues/48043#issuecomment-501416660" target="_blank" title="https://github.com/rust-lang/rust/issues/48043#issuecomment-501416660">https://github.com/rust-lang/rust/issues/48043#issuecomment-501416660</a> ?</p>



<a name="182124769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124769">(Nov 28 2019 at 17:23)</a>:</h4>
<p>Im not sure I fully understand what you are propossing, it feels as if you want all <code>Vec</code> methods to return a <code>Result</code></p>



<a name="182124817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124817">(Nov 28 2019 at 17:24)</a>:</h4>
<blockquote>
<p><code>AbortAlloc</code> is implemented as a wrapper around an arbitrary allocator <code>A</code>. <code>AbortAlloc</code> maps the returend error to <code>handle_alloc_error</code>. So if an OOM occures, there is no way to recover. Thus, <code>AbortAlloc</code> is incompatible with <code>try_reserve</code>. Any thoughts/idea on this?</p>
</blockquote>
<p>Yes, making the choice to abort or not be part of the type signature is incompatible with having it only as part of the choice of method being called on a given type. I personally prefer the latter.</p>



<a name="182124881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124881">(Nov 28 2019 at 17:24)</a>:</h4>
<blockquote>
<p>No, in today’s standard library it’s Vec and other callers that check for errors and call handle_alloc_error which in turn defaults to abort.</p>
</blockquote>
<p><span class="user-mention" data-user-id="219747">@Simon Sapin</span> yes, but I can provide a <code>#[global_allocator]</code> that aborts on OOM or panics instead by using <code>AbortOnOOM&lt;std::alloc::Heap&gt;;</code> right ?</p>



<a name="182124968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124968">(Nov 28 2019 at 17:26)</a>:</h4>
<p>I think <a href="https://github.com/rust-lang/rust/issues/48043#issuecomment-409967652" target="_blank" title="https://github.com/rust-lang/rust/issues/48043#issuecomment-409967652">https://github.com/rust-lang/rust/issues/48043#issuecomment-409967652</a> is the first in my thread. It's somewhat hard to follow the convo rereading it again I'll admit. These sorts of discussions tended to be strewn around a bunch of issues, sadly.</p>



<a name="182124987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124987">(Nov 28 2019 at 17:26)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> yes there should be a <code>try_</code> version of every method that returns a result.</p>



<a name="182124999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182124999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182124999">(Nov 28 2019 at 17:27)</a>:</h4>
<p>Ah gotcha</p>



<a name="182125007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125007">(Nov 28 2019 at 17:27)</a>:</h4>
<p>There’s nothing technically stopping you from aborting inside your <code>#[global_allocator]</code>, but <a href="https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html#errors" target="_blank" title="https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html#errors">https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html#errors</a> “encourages” not to</p>



<a name="182125011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125011">(Nov 28 2019 at 17:27)</a>:</h4>
<p>So do you want <code>try_clone</code> as well in the <code>Clone</code> trait ?</p>



<a name="182125026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125026">(Nov 28 2019 at 17:27)</a>:</h4>
<p>Probably yes</p>



<a name="182125037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125037">(Nov 28 2019 at 17:28)</a>:</h4>
<p>Like if I <code>extend</code> a <code>Vec&lt;T&gt;</code>, and <code>try_reserve</code> succeeded, but extending requires calls to <code>T::clone</code>, and those <code>T::clone</code> allocate, then, you are screwed</p>



<a name="182125083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125083">(Nov 28 2019 at 17:28)</a>:</h4>
<p>exactly!</p>



<a name="182125085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125085">(Nov 28 2019 at 17:28)</a>:</h4>
<p>I think the idea of an <code>AbortOnOOM</code> wrapper type is flawed</p>



<a name="182125095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125095">(Nov 28 2019 at 17:28)</a>:</h4>
<p>What's the goal of <code>AbortOnOOM</code> ?</p>



<a name="182125099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125099">(Nov 28 2019 at 17:28)</a>:</h4>
<p>the only way to systematically ensure your program will not crash is to never panic and <code>?</code> the <code>Result</code>  --- ideomatic error handling.</p>



<a name="182125105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125105">(Nov 28 2019 at 17:29)</a>:</h4>
<p>I don’t know, you mentioned it</p>



<a name="182125114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125114">(Nov 28 2019 at 17:29)</a>:</h4>
<p>I mentioned <code>PanicOnOOM</code></p>



<a name="182125117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125117">(Nov 28 2019 at 17:29)</a>:</h4>
<p>which is quite differently</p>



<a name="182125131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125131">(Nov 28 2019 at 17:29)</a>:</h4>
<p><a href="#narrow/stream/197181-t-libs.2Fwg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60/near/182124881" title="#narrow/stream/197181-t-libs.2Fwg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60/near/182124881">https://rust-lang.zulipchat.com/#narrow/stream/197181-t-libs.2Fwg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60/near/182124881</a></p>



<a name="182125143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125143">(Nov 28 2019 at 17:29)</a>:</h4>
<p>I was asking if that is a possibility</p>



<a name="182125185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125185">(Nov 28 2019 at 17:30)</a>:</h4>
<p>the non-try methods would require the allocator parameter to have <code>!</code> as the error type, which means that alllocation failure is "impossible", which means something panics. <code>PanicOnOOM</code> would have the <code>!</code> error  type.</p>



<a name="182125197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125197">(Nov 28 2019 at 17:30)</a>:</h4>
<p>and if your goal is to abort on any OOM, it is quite simple</p>



<a name="182125204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125204">(Nov 28 2019 at 17:30)</a>:</h4>
<p>and doesn't rely on anybody calling the <code>handle_alloc_error</code></p>



<a name="182125211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125211">(Nov 28 2019 at 17:30)</a>:</h4>
<p>It’s technically possible. IMO it’s not a good idea.</p>



<a name="182125213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125213">(Nov 28 2019 at 17:30)</a>:</h4>
<p>the same applies if you want to panic on any OOM</p>



<a name="182125216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125216">(Nov 28 2019 at 17:30)</a>:</h4>
<p>Why?</p>



<a name="182125243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125243">(Nov 28 2019 at 17:31)</a>:</h4>
<p>Why would you panic or abort if the caller has specifically written code to handle both outcomes of <code>try_reserve</code>?</p>



<a name="182125255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125255">(Nov 28 2019 at 17:31)</a>:</h4>
<p>That just seems hostile to me</p>



<a name="182125261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125261">(Nov 28 2019 at 17:32)</a>:</h4>
<p>Because if I'm writing <code>#[global_allocator]</code>, i'm in charge of building the final binary, and I can do whatever I want?</p>



<a name="182125301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125301">(Nov 28 2019 at 17:32)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> or you can read <a href="https://github.com/rust-lang/rust/pull/60703" target="_blank" title="https://github.com/rust-lang/rust/pull/60703">https://github.com/rust-lang/rust/pull/60703</a> where I implemented everything I've talked about</p>



<a name="182125328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125328">(Nov 28 2019 at 17:32)</a>:</h4>
<p>Like, maybe I just want my binary to fail as fast as possible on OOM without any kind of cleanup - its kind of up to me</p>



<a name="182125335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125335">(Nov 28 2019 at 17:32)</a>:</h4>
<p><span class="user-mention" data-user-id="219747">@Simon Sapin</span> with the associated error type <code>try_*</code> would return <code>Result&lt;_, !&gt;</code>, with <code>PanicOnOOM</code> so the  user gets a heads up that their code isn't doing what they through via dead code warnings.</p>



<a name="182125358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125358">(Nov 28 2019 at 17:33)</a>:</h4>
<p>One way to implement all standard collections more "concisely" would be to wrap the user allocator in a <code>HandleAllocError&lt;Alloc&gt;</code> wrapper internally, that always calls <code>handle_alloc_error</code> on OOM.</p>



<a name="182125365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125365">(Nov 28 2019 at 17:33)</a>:</h4>
<p><span class="user-mention" data-user-id="220594">@John Ericson</span> I’m sorry, you and I already had this discussion a couple times and I don’t have anything new to add</p>



<a name="182125426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125426">(Nov 28 2019 at 17:34)</a>:</h4>
<p>The things you are telling @gnzlbg seem like the same things you have told me?</p>



<a name="182125433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125433">(Nov 28 2019 at 17:34)</a>:</h4>
<p><span class="user-mention" data-user-id="220594">@John Ericson</span> I think the difference is that I'm not suggesting for everything to return <code>Result</code></p>



<a name="182125434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125434">(Nov 28 2019 at 17:34)</a>:</h4>
<p>I'll not @ you then and at @ <span class="user-mention" data-user-id="132920">@gnzlbg</span> instead, I guess</p>



<a name="182125435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125435">(Nov 28 2019 at 17:34)</a>:</h4>
<p>I meant about <code>Result&lt;_, !&gt;</code> everywhere</p>



<a name="182125449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125449">(Nov 28 2019 at 17:35)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> so without a bunch of new <code>try_</code> methods, what are you proposing for writing code that never blows up on allocation failure?</p>



<a name="182125453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125453">(Nov 28 2019 at 17:35)</a>:</h4>
<p><code>Vec&lt;T, PanicOnOOM&lt;Alloc&gt;&gt;</code></p>



<a name="182125464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125464">(Nov 28 2019 at 17:35)</a>:</h4>
<p>that still panics?</p>



<a name="182125470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125470">(Nov 28 2019 at 17:35)</a>:</h4>
<p>it immediately panics, always</p>



<a name="182125473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125473">(Nov 28 2019 at 17:35)</a>:</h4>
<p>is the application supposed to catch the panic?</p>



<a name="182125515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125515">(Nov 28 2019 at 17:36)</a>:</h4>
<p>Yes, it could, if it wanted</p>



<a name="182125517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125517">(Nov 28 2019 at 17:36)</a>:</h4>
<p>Say you don't want to panic or abort</p>



<a name="182125520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125520">(Nov 28 2019 at 17:36)</a>:</h4>
<p>Only works with unwinding</p>



<a name="182125529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125529">(Nov 28 2019 at 17:36)</a>:</h4>
<p>If you don't have unwinding, or don't want to unwind, this won't work for you</p>



<a name="182125534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125534">(Nov 28 2019 at 17:36)</a>:</h4>
<p>that's why I want <code>try_*</code></p>



<a name="182125551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125551">(Nov 28 2019 at 17:37)</a>:</h4>
<p>I want my code to not fail, and so I don't write any panics, and I cannot unwind so I do panic == abort</p>



<a name="182125556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125556">(Nov 28 2019 at 17:37)</a>:</h4>
<p>But if you want to support <code>Vec&lt;T&gt;</code> failing to resize, <code>T::clone</code> failing, etc. , a global allocator that panics on OOM, and an allocator wrapper that panics on OOM, give you that if you have unwinding</p>



<a name="182125561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125561">(Nov 28 2019 at 17:37)</a>:</h4>
<p>And it gives you that without having <code>Result</code> everywhere</p>



<a name="182125571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125571">(Nov 28 2019 at 17:37)</a>:</h4>
<p>Isn't <code>Result</code> everywhere the ideomatic way of doing error handling in rust?</p>



<a name="182125575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125575">(Nov 28 2019 at 17:37)</a>:</h4>
<p>and catching panics <em>not</em>?</p>



<a name="182125577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125577">(Nov 28 2019 at 17:37)</a>:</h4>
<p>Not for allocation errors</p>



<a name="182125621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125621">(Nov 28 2019 at 17:38)</a>:</h4>
<p>why is allocation different?</p>



<a name="182125624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125624">(Nov 28 2019 at 17:38)</a>:</h4>
<p>Because somebody decided so</p>



<a name="182125632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125632">(Nov 28 2019 at 17:38)</a>:</h4>
<p>That decision happened long time ago, and we can't change it</p>



<a name="182125635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125635">(Nov 28 2019 at 17:38)</a>:</h4>
<p>Right we have some legacy cruft, but I rather things be different for principled reasons.</p>



<a name="182125643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125643">(Nov 28 2019 at 17:38)</a>:</h4>
<p>You can write RFCs for adding a lot of try_methods, and maybe they'll go through</p>



<a name="182125665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125665">(Nov 28 2019 at 17:39)</a>:</h4>
<p>But for me, unwinding is ok, and a small <code>Alloc&lt;A&gt;</code> wrapper makes allocation fallible, without having to change anything or add any APIs</p>



<a name="182125670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125670">(Nov 28 2019 at 17:39)</a>:</h4>
<p>Or rely on people actually using those APIs</p>



<a name="182125681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125681">(Nov 28 2019 at 17:39)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> so what makes this difficult is to me <code>PanicOnOOM</code>, <code>Result</code>, and <code>try_*</code> all go together.</p>



<a name="182125684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125684">(Nov 28 2019 at 17:39)</a>:</h4>
<p>I need all 3 of them to make the coherent argument</p>



<a name="182125692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125692">(Nov 28 2019 at 17:40)</a>:</h4>
<p>I don't need Result and try_</p>



<a name="182125736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125736">(Nov 28 2019 at 17:40)</a>:</h4>
<p>What does <code>PanicOnOOM</code> do without <code>try_*</code>?</p>



<a name="182125737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125737">(Nov 28 2019 at 17:40)</a>:</h4>
<p>because I have unwinding, and can use it to handle OOM</p>



<a name="182125748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125748">(Nov 28 2019 at 17:40)</a>:</h4>
<p>Say you <em>diddn't</em> use <code>PanicOnOOM</code>. What would happen?</p>



<a name="182125759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125759">(Nov 28 2019 at 17:40)</a>:</h4>
<p><code>PanicOom&lt;A: Alloc&gt;: Alloc</code> is an allocator wrapper, that forwards arguments and returns from / to <code>A</code>, but if a return is a null pointer due to an allocation error, it immediately panics.</p>



<a name="182125780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125780">(Nov 28 2019 at 17:41)</a>:</h4>
<p>So what happens if I try to do <code>Vec&lt;A&gt;</code> without <code>Vec&lt;PanicOnOOM&lt;A&gt;</code></p>



<a name="182125789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125789">(Nov 28 2019 at 17:41)</a>:</h4>
<p>and <code>A</code> returns a null pointer</p>



<a name="182125802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125802">(Nov 28 2019 at 17:41)</a>:</h4>
<p>If <code>A</code> forwards to the <code>#[global_allocator]</code> then that would panic, if you make it a <code>PanicOnOOM</code></p>



<a name="182125862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125862">(Nov 28 2019 at 17:42)</a>:</h4>
<p>If <code>A</code> is its own thing, it would call <code>handle_alloc_err</code> at some point, which you can configure to also panic</p>



<a name="182125873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125873">(Nov 28 2019 at 17:42)</a>:</h4>
<p>panic or abort, right?</p>



<a name="182125874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125874">(Nov 28 2019 at 17:43)</a>:</h4>
<p>but then you are relying on <code>Vec</code> always calling <code>handle_alloc_err</code> when it should</p>



<a name="182125883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125883">(Nov 28 2019 at 17:43)</a>:</h4>
<p>You can provide your own handler</p>



<a name="182125896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125896">(Nov 28 2019 at 17:43)</a>:</h4>
<p>So in my case, I would provide a <code>PanicOnOom</code> global allocator, a handler that panics, etc.</p>



<a name="182125897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125897">(Nov 28 2019 at 17:43)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> I don't feel very motivated by your <code>PanicOnOOM</code></p>



<a name="182125902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125902">(Nov 28 2019 at 17:43)</a>:</h4>
<p>So it always panics</p>



<a name="182125910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125910">(Nov 28 2019 at 17:43)</a>:</h4>
<p>and we just muddle who has the oblilgation</p>



<a name="182125916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125916">(Nov 28 2019 at 17:43)</a>:</h4>
<p>yes, and I can catch those panics, if I care about that, and where I care about that</p>



<a name="182125925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125925">(Nov 28 2019 at 17:43)</a>:</h4>
<p>it would be nice to say "Vec, you don't need to worry about null pointers because that is already taken care of"</p>



<a name="182125978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125978">(Nov 28 2019 at 17:44)</a>:</h4>
<p>but you cannot rely on the allocator using <code>PanicOnOOM</code> so Vec has to be defensive anyways</p>



<a name="182125984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125984">(Nov 28 2019 at 17:44)</a>:</h4>
<p>so you get both sides panicking</p>



<a name="182125988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182125988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182125988">(Nov 28 2019 at 17:44)</a>:</h4>
<p>what's the point?</p>



<a name="182126005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126005">(Nov 28 2019 at 17:44)</a>:</h4>
<p>That there are collections that are not <code>Vec</code> that I also use</p>



<a name="182126010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126010">(Nov 28 2019 at 17:44)</a>:</h4>
<p>inside the 100s of my crates I depend on</p>



<a name="182126012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126012">(Nov 28 2019 at 17:44)</a>:</h4>
<p>and I don't trustthem</p>



<a name="182126020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126020">(Nov 28 2019 at 17:44)</a>:</h4>
<p>But they either need to return <code>Result</code>, or panic themselves</p>



<a name="182126032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126032">(Nov 28 2019 at 17:45)</a>:</h4>
<p>the type system forces this</p>



<a name="182126046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126046">(Nov 28 2019 at 17:45)</a>:</h4>
<p>Are you worried about those other collections just not handling null pointers at all?</p>



<a name="182126103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126103">(Nov 28 2019 at 17:46)</a>:</h4>
<p>Then the solution is to make sure that no collection needs to worry about nullness</p>



<a name="182126129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126129">(Nov 28 2019 at 17:46)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> here's the thing, even if every collection is to be used with OOM panics and unwinding, when <em>building</em> collections it's much easier to use <code>Result</code></p>



<a name="182126136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126136">(Nov 28 2019 at 17:47)</a>:</h4>
<p>You don't have to be a careful C programmer and remember all your null pointers</p>



<a name="182126144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126144">(Nov 28 2019 at 17:47)</a>:</h4>
<p>and collections can be made out of other collections, etc etc</p>



<a name="182126150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126150">(Nov 28 2019 at 17:47)</a>:</h4>
<p>therefore I don't recognize there being a clear division of labor between "collections code" and "applications code"</p>



<a name="182126220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182126220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182126220">(Nov 28 2019 at 17:48)</a>:</h4>
<p>It's best if we just add all the <code>try_</code> methods and associated error type so we can safely create all these other collections, and the responsibility for error handling is clearly laid out and no one needs to be defense without help from the compiler. Nobody is being forced to use the <code>try_*</code> methods, remember.</p>



<a name="182130211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130211">(Nov 28 2019 at 19:01)</a>:</h4>
<blockquote>
<p>I think the idea of an <code>AbortOnOOM</code> wrapper type is flawed</p>
</blockquote>
<p>Yes it is, that's the reason why I removed it from alloc-wg. The thing is, that it will always aborts (or panics in the case of <code>PanicOnOom</code>) as soon as an allocation fails, even before <code>try_reserve</code> can return a result.</p>
<p>Personally I'm not fine with relying on unwinding on OOM. That defeats the purpose on returning a Result. Personally I also think, that the current design of the collections isn't that great, but we can't change this anyway, so we shouldn't bother.</p>



<a name="182130478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130478">(Nov 28 2019 at 19:06)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> I would be happy to contribute my PR to that library</p>



<a name="182130498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130498">(Nov 28 2019 at 19:07)</a>:</h4>
<p>I don't get all this "ship has sailed" talk when there is no problem with adding a bunch of new methods</p>



<a name="182130550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130550">(Nov 28 2019 at 19:08)</a>:</h4>
<p>And there could be some lang thing down the road for Result&lt;T,!&gt; to T</p>



<a name="182130562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130562">(Nov 28 2019 at 19:08)</a>:</h4>
<p>So it's not like 2x methods is necessary a permanent state of affairs</p>



<a name="182130585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130585">(Nov 28 2019 at 19:09)</a>:</h4>
<p>Sure, go ahead and let's see, how it turns out. The crate tries to collect proposals of the WG to try them, not to be merged as the new liballoc.</p>



<a name="182130599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130599">(Nov 28 2019 at 19:09)</a>:</h4>
<p>Ok thanks</p>



<a name="182130612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130612">(Nov 28 2019 at 19:09)</a>:</h4>
<blockquote>
<p>I don't get all this "ship has sailed" talk</p>
</blockquote>
<p>Me neither</p>



<a name="182130794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130794">(Nov 28 2019 at 19:13)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> now I'm confused :) Didn't you just say "but we can't change this anyway"? Or were you referring to something more specific?</p>



<a name="182130805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130805">(Nov 28 2019 at 19:13)</a>:</h4>
<p>A few commits back you can see the design with <code>AbortAlloc</code> and the bound for <code>AllocRed&lt;Error = !&gt;</code> for infallible methods .</p>



<a name="182130865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130865">(Nov 28 2019 at 19:14)</a>:</h4>
<p>Wait a second searching for a cite</p>



<a name="182130872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182130872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182130872">(Nov 28 2019 at 19:14)</a>:</h4>
<p>OK</p>



<a name="182131163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182131163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182131163">(Nov 28 2019 at 19:20)</a>:</h4>
<p>Can't find it right now. However I don't see why the collections defaults to abort instead of panicking. Or even don't return <code>Result</code></p>



<a name="182131175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182131175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182131175">(Nov 28 2019 at 19:20)</a>:</h4>
<p>OK, sweet!</p>



<a name="182131308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182131308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182131308">(Nov 28 2019 at 19:23)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> oh, looks like alloc-wg does a lot of this stuff already?! Sorry, I am comming back to these things after quite a while</p>



<a name="182132562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182132562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182132562">(Nov 28 2019 at 19:51)</a>:</h4>
<p>No problem :D</p>



<a name="182132648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182132648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182132648">(Nov 28 2019 at 19:52)</a>:</h4>
<p>As mentioned before: I tried to collect many proposals so it turns out how much sense everything makes.</p>



<a name="182171590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182171590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182171590">(Nov 29 2019 at 11:55)</a>:</h4>
<blockquote>
<p>Yes it is, that's the reason why I removed it from alloc-wg. The thing is, that it will always aborts (or panics in the case of PanicOnOom) as soon as an allocation fails, even before try_reserve can return a result.</p>
</blockquote>
<p>That is kind of the point right? What can you do to prevent this from happening? e.g. I can write an <code>AbortOnOom</code> wrapper that sets the <code>#[global_allocator]</code> to abort on OOM, and there is nothing the standard library can do against that.</p>



<a name="182171798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182171798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182171798">(Nov 29 2019 at 11:58)</a>:</h4>
<p>For something like <code>PanicOnOom</code>, we can protect against this by saying that a <code>GlobalAlloc</code> that unwinds is UB, and e.g. making the <code>GlobalAlloc</code> hooks <code>nounwind</code>, to be able to optimize under this assumption.</p>



<a name="182171826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182171826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182171826">(Nov 29 2019 at 11:59)</a>:</h4>
<p>But if you write a library that uses <code>Vec::try_reserve</code>, you are not guaranteed a <code>Result</code> on allocation error, because your allocator might abort the process if that happens, and there is nothing you can do about that.</p>



<a name="182171841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182171841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182171841">(Nov 29 2019 at 12:00)</a>:</h4>
<p>On Linux, you might get even an <code>Ok</code>, and only when you touch the memory, the OOM-killer kills your process</p>



<a name="182171913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182171913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182171913">(Nov 29 2019 at 12:01)</a>:</h4>
<p>So the best that <code>Vec::try_reserve</code> can do is guarantee that <code>handle_alloc_error</code> won't be called</p>



<a name="182172002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172002">(Nov 29 2019 at 12:02)</a>:</h4>
<p>which is very different from the guarantee that allocation errors will be reported as <code>Err</code>, there is no way to guarantee that in Rust</p>



<a name="182172033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172033">(Nov 29 2019 at 12:02)</a>:</h4>
<p>you need the allocator and the OS to conspire together with <code>Vec::try_reserve</code> to support those semantics</p>



<a name="182172161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172161">(Nov 29 2019 at 12:04)</a>:</h4>
<p>(the goal of <code>Vec::try_reserve</code> is to support supporting those semantics when all those components align)</p>



<a name="182172559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172559">(Nov 29 2019 at 12:10)</a>:</h4>
<blockquote>
<p>That is kind of the point right?</p>
</blockquote>
<p>I tried to modify the collection API, that allocating methods like <code>Vec::reserve</code> can only be used for infallible allocators (<code>AllocRef&lt;Error = !&gt;</code>). To maintain backwards combatibility, I introduced the wrapping allocator <code>AbortAlloc</code>.</p>



<a name="182172593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172593">(Nov 29 2019 at 12:11)</a>:</h4>
<p>To achieve this, the design of <code>AbortAlloc</code> simply didn't work out</p>



<a name="182172624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172624">(Nov 29 2019 at 12:11)</a>:</h4>
<p>Ah yes, that won't work</p>



<a name="182172693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172693">(Nov 29 2019 at 12:12)</a>:</h4>
<p>What I think could be done is provide a different <code>FallibleVec</code> in libstd, where all allocating methods return <code>Result&lt;(), AllocRef::Error&gt;</code> or some other error type.</p>



<a name="182172698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172698">(Nov 29 2019 at 12:12)</a>:</h4>
<p>This brings me to two points:<br>
- Does an infallible generic allocator even makes sense?<br>
- I think this could only be solved with an additional trait: <code>InfallibleAlloc</code> (and <code>InfallibleRealloc</code>?)</p>



<a name="182172709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172709">(Nov 29 2019 at 12:12)</a>:</h4>
<p>Then, <code>Vec</code> can be implemented on top of such a <code>FallibleVec</code> type by just <code>.unwrap()</code>ing everything</p>



<a name="182172746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172746">(Nov 29 2019 at 12:13)</a>:</h4>
<blockquote>
<p>What I think could be done is provide a different FallibleVec in libstd</p>
</blockquote>
<p>Right, this would be another possibility</p>



<a name="182172748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172748">(Nov 29 2019 at 12:13)</a>:</h4>
<p>If we ever get a <code>prelude::v2</code> in a future edition, we could add a <code>Vec</code> type alias for <code>FallibleVec</code></p>



<a name="182172754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172754">(Nov 29 2019 at 12:13)</a>:</h4>
<p>and offer the old Vec through a <code>std::v1::collections::Vec</code>.</p>



<a name="182172768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172768">(Nov 29 2019 at 12:13)</a>:</h4>
<p>Only for crates on the new edition, on the old edition, the prelude would just point to <code>v1</code>, so that would be a backward compatible change.</p>



<a name="182172828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172828">(Nov 29 2019 at 12:14)</a>:</h4>
<p>Code in the new edition interfacing with APIs from crates using the old edition using <code>Vec</code>, would need to use <code>std::v1::collection::Vec</code> instead, so this might end up being quite a pain, but... is doable.</p>



<a name="182172838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172838">(Nov 29 2019 at 12:14)</a>:</h4>
<p>I think introducing <code>FallibleVec</code> wouldn't be the optimal solution, as <code>Vec</code> isn't the only collection which allocates. We would need a fallible variant for all collections</p>



<a name="182172844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172844">(Nov 29 2019 at 12:14)</a>:</h4>
<p>Yes</p>



<a name="182172850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172850">(Nov 29 2019 at 12:14)</a>:</h4>
<p>but we can do that one collection at a time</p>



<a name="182172877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172877">(Nov 29 2019 at 12:15)</a>:</h4>
<p>without breaking backward compatibility, and just changing what the defaults are between editions, while providing both version on all editions</p>



<a name="182172896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172896">(Nov 29 2019 at 12:15)</a>:</h4>
<p>What do you think on introducing <code>liballoc::alloc::Infallible</code>?</p>



<a name="182172898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172898">(Nov 29 2019 at 12:15)</a>:</h4>
<p>as trait</p>



<a name="182172997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182172997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182172997">(Nov 29 2019 at 12:17)</a>:</h4>
<p>What does that mean ?</p>



<a name="182173006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182173006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182173006">(Nov 29 2019 at 12:17)</a>:</h4>
<p>An alloc that impls <code>Infallible</code> never fails ?</p>



<a name="182173027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182173027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182173027">(Nov 29 2019 at 12:17)</a>:</h4>
<p>Kind of, an alloc, which will never return on OOM</p>



<a name="182173112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182173112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182173112">(Nov 29 2019 at 12:19)</a>:</h4>
<p>But I don't know if we end up with the same problem...</p>



<a name="182173215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182173215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182173215">(Nov 29 2019 at 12:21)</a>:</h4>
<p>We shouldn't forget that most of the users will never use or write a custom allocator or even use <code>try_reserve</code>.</p>



<a name="182173288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182173288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182173288">(Nov 29 2019 at 12:22)</a>:</h4>
<p>So we shouldn't clutter the namespace with too much types.</p>



<a name="182173477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182173477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182173477">(Nov 29 2019 at 12:25)</a>:</h4>
<p>But the question remains: How much sense does a generic infallible allocator make? Won't all allocator OOM at a time without introducing additional constraints?</p>



<a name="182186502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182186502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182186502">(Nov 29 2019 at 15:38)</a>:</h4>
<p>I think that until somebody actually tries to implement this, and shows how it is used to implement <code>Vec</code>, and then how <code>Vec</code> is end up being used, it will be very hard to tell.</p>



<a name="182186624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182186624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182186624">(Nov 29 2019 at 15:40)</a>:</h4>
<p>I'm skeptic that it will be as useful as <span class="user-mention" data-user-id="220594">@John Ericson</span> says,  but I'm also skeptic about this being completely useless, as <span class="user-mention" data-user-id="219747">@Simon Sapin</span> seems to believe. I'll probably only be able to tell when I see both options next to each other.</p>



<a name="182186647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182186647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182186647">(Nov 29 2019 at 15:40)</a>:</h4>
<p><code>Vec::try_reserve</code> is a solution that's a bit "in-between", and maybe it is the best solution there is. No idea yet.</p>



<a name="182221300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182221300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182221300">(Nov 30 2019 at 04:02)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span>  I am working on my allog-wg, why does <code>Box</code> use unchecked stuff?</p>



<a name="182233854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182233854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182233854">(Nov 30 2019 at 10:37)</a>:</h4>
<p>That's a good catch. I forgot to remove it when I removed <code>AbortAlloc</code>, thanks</p>



<a name="182234499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182234499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182234499">(Nov 30 2019 at 10:56)</a>:</h4>
<p>You basically reverted my <code>AbortAlloc</code> :D</p>



<a name="182241121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241121">(Nov 30 2019 at 14:24)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> I tried to find <code>AbortAlloc</code> but didn't, thanks</p>



<a name="182241130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241130">(Nov 30 2019 at 14:25)</a>:</h4>
<p>I removed it at 0.7.0. You can find it in the docs for 0.6.0</p>



<a name="182241137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241137">(Nov 30 2019 at 14:25)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> OK I read your explanation, thanks, and I think I get it now</p>



<a name="182241188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241188">(Nov 30 2019 at 14:26)</a>:</h4>
<p>So this goes back to what <span class="user-mention" data-user-id="132920">@gnzlbg</span> said about it might be best to change the meaning of <code>try_reserve</code></p>



<a name="182241192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241192">(Nov 30 2019 at 14:26)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> and I thought about another solution yesterday, you can see the discussion above :)</p>



<a name="182241204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241204">(Nov 30 2019 at 14:27)</a>:</h4>
<p><code>FallibleVec</code>?</p>



<a name="182241207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241207">(Nov 30 2019 at 14:27)</a>:</h4>
<p>I think the current meaning of <code>try_reserve</code> is intuitive, don't you?</p>



<a name="182241213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241213">(Nov 30 2019 at 14:27)</a>:</h4>
<p>Well let's  just talk about <code>FallibleVec</code> for a second</p>



<a name="182241253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241253">(Nov 30 2019 at 14:28)</a>:</h4>
<p>- <code>FallibleVec</code>, but this introduces a lot more structures<br>
- <code>Infallible</code> as another alloc trait is another option</p>



<a name="182241254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241254">(Nov 30 2019 at 14:28)</a>:</h4>
<p>sure!</p>



<a name="182241259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241259">(Nov 30 2019 at 14:28)</a>:</h4>
<p>So we have this split ecosytem that's part "I don't care about allocation failure" and "I really care about allocation failure"</p>



<a name="182241265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241265">(Nov 30 2019 at 14:28)</a>:</h4>
<p>Yeah, true</p>



<a name="182241269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241269">(Nov 30 2019 at 14:28)</a>:</h4>
<p>I want there to be libraries that support both</p>



<a name="182241285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241285">(Nov 30 2019 at 14:29)</a>:</h4>
<p>Me too. The best case would be an API which supports both</p>



<a name="182241286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241286">(Nov 30 2019 at 14:29)</a>:</h4>
<p>My best idea for that is the with the <code>foo</code> = <code>try_foo.infallible_unwrap()</code> pattern</p>



<a name="182241292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241292">(Nov 30 2019 at 14:29)</a>:</h4>
<p>Is <code>FallibleVec</code> supposed to be a whole different struct?</p>



<a name="182241341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241341">(Nov 30 2019 at 14:30)</a>:</h4>
<p>Maybe a more compatible with the above alternative would be an extension trait that you don't get in the prelude, so regular users aren't confused?</p>



<a name="182241356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241356">(Nov 30 2019 at 14:30)</a>:</h4>
<p>Also I think a <code>type Panic = !</code> would make things a lot more intuitive?</p>



<a name="182241357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241357">(Nov 30 2019 at 14:30)</a>:</h4>
<blockquote>
<p>Maybe a more compatible with the above alternative would be an extension trait that you don't get in the prelude, so regular users aren't confused?</p>
</blockquote>
<p>I thought about that, too</p>



<a name="182241367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241367">(Nov 30 2019 at 14:31)</a>:</h4>
<blockquote>
<p>Also I think a type Panic = ! would make things a lot more intuitive?</p>
</blockquote>
<p>Yes, indeed. That's why I really  liked the <code>AllocRef&lt;Error = !&gt;</code> approach</p>



<a name="182241368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241368">(Nov 30 2019 at 14:31)</a>:</h4>
<p>If you see <code>fn try_reserve(&amp;mut self) -&gt; Result&lt;(), Panic&gt;</code>, &lt;- after subsitutition, I think it makes a bit more sense what is going on.</p>



<a name="182241489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241489">(Nov 30 2019 at 14:35)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> so back to the test failures, is this just a matter of changing the tests?</p>



<a name="182241493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241493">(Nov 30 2019 at 14:35)</a>:</h4>
<p>In the current state (0.7.0), you can just call <code>reserve</code> and it will abort on OOM. However, when calling <code>try_reserve</code> it will return <code>Result&lt;(), Err&gt;</code>. If your allocator never fails, it still returns <code>Return&lt;(), !&gt;</code>, which is pretty intuitive. The user, who don't care about fallible collections can still use <code>reserve</code>. Do I get you right, that you want to introduce all the <code>try_</code> methods in an extension traits excluded from the prelude?</p>



<a name="182241547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241547">(Nov 30 2019 at 14:36)</a>:</h4>
<p>You can fix this when exchanging <code>AbortAlloc&lt;Global&gt;</code> (forgot your name :) ) with <code>Global</code>. This requires a bit of dancing for the <code>String</code> tests, but it's possible. Let me search the commit, where I fixed this test - I also had those failures before.</p>



<a name="182241605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241605">(Nov 30 2019 at 14:38)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> also in general, sorry for making a bug fuss and not finding the commits that showed you had tried all of the stuff in that PR.</p>



<a name="182241606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241606">(Nov 30 2019 at 14:39)</a>:</h4>
<p>I've wasted both our time <span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>



<a name="182241612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241612">(Nov 30 2019 at 14:39)</a>:</h4>
<p>I found the tests commit now</p>



<a name="182241614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241614">(Nov 30 2019 at 14:39)</a>:</h4>
<p>for <code>Vec</code>: <a href="https://github.com/TimDiekmann/alloc-wg/pull/10/commits/dfa9939e4bd6007fcd9d5a89537d3081ef1634a7" target="_blank" title="https://github.com/TimDiekmann/alloc-wg/pull/10/commits/dfa9939e4bd6007fcd9d5a89537d3081ef1634a7">https://github.com/TimDiekmann/alloc-wg/pull/10/commits/dfa9939e4bd6007fcd9d5a89537d3081ef1634a7</a><br>
for <code>String</code>: <a href="https://github.com/TimDiekmann/alloc-wg/pull/10/commits/06fff0335cc00abf195659056cb52286b43b43d5" target="_blank" title="https://github.com/TimDiekmann/alloc-wg/pull/10/commits/06fff0335cc00abf195659056cb52286b43b43d5">https://github.com/TimDiekmann/alloc-wg/pull/10/commits/06fff0335cc00abf195659056cb52286b43b43d5</a></p>



<a name="182241615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241615">(Nov 30 2019 at 14:39)</a>:</h4>
<p>Me too <span aria-label="yum" class="emoji emoji-1f60b" role="img" title="yum">:yum:</span></p>



<a name="182241669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241669">(Nov 30 2019 at 14:40)</a>:</h4>
<p>I think you better "waste" my time for one hour, than don't participate at all :)<br>
Now you know about my design decisions, so don't worry <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="182241688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241688">(Nov 30 2019 at 14:41)</a>:</h4>
<p>Don't know if the second commit is required now, but the first definitely fixed your test case</p>



<a name="182241748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241748">(Nov 30 2019 at 14:43)</a>:</h4>
<p>But back to the design: I don't think we should stick with <code>AbortAlloc</code>/<code>PanicAdapter</code> at all. Do you want to try out, how the extension trait works out?<br>
Personally, I'd love to have more traits on collections anyway, but this is another story.</p>



<a name="182241793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241793">(Nov 30 2019 at 14:44)</a>:</h4>
<p>Like generic traits for slicing, random access, len etc.</p>



<a name="182241799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182241799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182241799">(Nov 30 2019 at 14:44)</a>:</h4>
<p>But this wasn't done yet due to the lack of GAT</p>



<a name="182242542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242542">(Nov 30 2019 at 15:06)</a>:</h4>
<p>GAT?</p>



<a name="182242552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242552">(Nov 30 2019 at 15:07)</a>:</h4>
<p>Generic associated type</p>



<a name="182242558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242558">(Nov 30 2019 at 15:07)</a>:</h4>
<p>ah ok</p>



<a name="182242559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242559">(Nov 30 2019 at 15:07)</a>:</h4>
<p>yeah it is ugly without it</p>



<a name="182242565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242565">(Nov 30 2019 at 15:07)</a>:</h4>
<p>So if you like <code>type Panic = !</code>, what is the remaing issue with the adapter?</p>



<a name="182242610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242610">(Nov 30 2019 at 15:08)</a>:</h4>
<p>Or really, I am much more fond of the <code>Error = !</code> bounds than the adapter itself</p>



<a name="182242616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242616">(Nov 30 2019 at 15:08)</a>:</h4>
<p>I combined my work with the reverts or reverts, and the tests pass now</p>



<a name="182242618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242618">(Nov 30 2019 at 15:08)</a>:</h4>
<p>fwiw</p>



<a name="182242633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242633">(Nov 30 2019 at 15:09)</a>:</h4>
<p>Calling <code>try_reserve</code> with <code>AbortAlloc</code> has an unintuitive behavior: It aborts on OOM. When <code>AbortAlloc</code> is the default for <code>Vec</code>, <code>try_reserve</code> is pretty useless for non-custom allocators</p>



<a name="182242697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242697">(Nov 30 2019 at 15:11)</a>:</h4>
<p>The expected behavior would be, that it aborts on <code>reserve</code> and returns a result on <code>try_reserve</code></p>



<a name="182242700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242700">(Nov 30 2019 at 15:11)</a>:</h4>
<p>But without an additional trait or more methods in <code>ReallocRef</code> this isn't possible</p>



<a name="182242763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242763">(Nov 30 2019 at 15:12)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> Are you just worried about <code>try_reserve</code>, or all such <code>try_*</code> methods?</p>



<a name="182242770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242770">(Nov 30 2019 at 15:12)</a>:</h4>
<p>All <code>try_*</code> methods</p>



<a name="182242789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242789">(Nov 30 2019 at 15:13)</a>:</h4>
<p>So we could do some associated type monstrosity to fix this</p>



<a name="182242798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242798">(Nov 30 2019 at 15:13)</a>:</h4>
<p>But <code>try_reserve</code> is the most intuitive example. What's the point on having <code>Vec::&lt;T, AbortAlloc&lt;Global&gt;&gt;::try_reserve</code> if it only checks for capacity overflow?</p>



<a name="182242852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242852">(Nov 30 2019 at 15:14)</a>:</h4>
<p>so, this would be </p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vec</span><span class="o">!</span><span class="p">[];</span><span class="w"></span>
<span class="n">v</span><span class="p">.</span><span class="n">try_reserve</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="o">?</span><span class="p">;</span><span class="w"> </span><span class="c1">// may abort</span>
</pre></div>



<a name="182242861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242861">(Nov 30 2019 at 15:15)</a>:</h4>
<p>Yes, the point is just so <code>reserve</code> can be written in terms of <code>try_reserve</code></p>



<a name="182242867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242867">(Nov 30 2019 at 15:15)</a>:</h4>
<p>BTW, how does capacity overlow happen without an alloc failure? Shouldn't it be underflow?</p>



<a name="182242870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242870">(Nov 30 2019 at 15:15)</a>:</h4>
<p>You can still do this, but you get the desired behavior when not using <code>AbortAlloc</code> and dropping the <code>Error = !</code> bound</p>



<a name="182242932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242932">(Nov 30 2019 at 15:17)</a>:</h4>
<p>capacity overflow may only occure on 16bit and 32 bit platforms, as only <code>isize</code> capacity is allowed there. If you try to reserve <code>isize::MAX / 4</code> slots with <code>size_of::&lt;T&gt;() == 8</code> it will overflow</p>



<a name="182242983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242983">(Nov 30 2019 at 15:18)</a>:</h4>
<p>Wouldn't that also be an allocation failure?</p>



<a name="182242988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182242988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182242988">(Nov 30 2019 at 15:18)</a>:</h4>
<p>err nevermind</p>



<a name="182243021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243021">(Nov 30 2019 at 15:19)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> So honestly if what is in alloc-wg landed soon, and the <code>try_*</code> methods were unstable until GAT, I would be perfectly happy</p>



<a name="182243024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243024">(Nov 30 2019 at 15:19)</a>:</h4>
<p>what do you think about that?</p>



<a name="182243187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243187">(Nov 30 2019 at 15:24)</a>:</h4>
<blockquote>
<p>Wouldn't that also be an allocation failure?</p>
</blockquote>
<p>Yes, but currently <code>CapacityOverflow</code> simply panics in <code>RawVec::reserve</code>. In <code>RawVec::try_reserve</code> it returns <code>Err(CapacityAllocError::CapacityOverflow)</code>.<br>
<code>Vec::try_reserve</code> also returns <code>Result&lt;(), CapacityAllocError&gt;</code>, but only the <code>CapacityOverflow</code> variant.</p>



<a name="182243217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243217">(Nov 30 2019 at 15:25)</a>:</h4>
<p>Even if the alloc-wg stuff will be merged upstream, it will take at least a year I guess until anything is stabilized. GATs are not required for the <code>try_*</code> methods, only for other trait methods on collections, but this is another story and probably out of scope for this WG (currently).</p>



<a name="182243266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243266">(Nov 30 2019 at 15:26)</a>:</h4>
<p>It might be for like <code>clone_in</code> and other multi-allocator ones?</p>



<a name="182243330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243330">(Nov 30 2019 at 15:28)</a>:</h4>
<p>No, generic trait methods for more collections. <code>CloneIn</code> is possible without GATs, too. However, even if a trait would need GATs I'd also be fine waiting for it. We shouldn't make the API more complicated than necessary, only because an approved language feature isn't completed yet.</p>



<a name="182243346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243346">(Nov 30 2019 at 15:29)</a>:</h4>
<p>sorry <code>try_clone_in</code> if we wanted to somehow gate that too</p>



<a name="182243398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243398">(Nov 30 2019 at 15:30)</a>:</h4>
<p><a href="https://docs.rs/alloc-wg/0.7.0/alloc_wg/clone/trait.CloneIn.html#tymethod.try_clone_in" target="_blank" title="https://docs.rs/alloc-wg/0.7.0/alloc_wg/clone/trait.CloneIn.html#tymethod.try_clone_in"><code>try_clone_in</code></a> <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="182243407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243407">(Nov 30 2019 at 15:31)</a>:</h4>
<p>Oh right, that workaround</p>



<a name="182243411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243411">(Nov 30 2019 at 15:31)</a>:</h4>
<p>And an additional trait could also use it</p>



<a name="182243412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243412">(Nov 30 2019 at 15:31)</a>:</h4>
<p>master doc: <a href="https://timdiekmann.github.io/alloc-wg/alloc_wg/clone/trait.CloneIn.html#tymethod.try_clone_in" target="_blank" title="https://timdiekmann.github.io/alloc-wg/alloc_wg/clone/trait.CloneIn.html#tymethod.try_clone_in">https://timdiekmann.github.io/alloc-wg/alloc_wg/clone/trait.CloneIn.html#tymethod.try_clone_in</a></p>



<a name="182243473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243473">(Nov 30 2019 at 15:33)</a>:</h4>
<p>But I'm unsure about the error type there. The error type may should be associated with the <code>CloneIn</code> trait itself, so we can return <code>CollectionAllocErr</code> to retrieve the layout</p>



<a name="182243478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243478">(Nov 30 2019 at 15:33)</a>:</h4>
<p>This is dropped <a href="https://timdiekmann.github.io/alloc-wg/src/alloc_wg/vec.rs.html#2215" target="_blank" title="https://timdiekmann.github.io/alloc-wg/src/alloc_wg/vec.rs.html#2215">here</a></p>



<a name="182243533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243533">(Nov 30 2019 at 15:34)</a>:</h4>
<p>Ah that</p>



<a name="182243534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243534">(Nov 30 2019 at 15:34)</a>:</h4>
<p><span class="user-mention" data-user-id="220594">@John Ericson</span>  To finish this topic, do you agree that <code>AbortAlloc</code> makes no sense like this?</p>



<a name="182243558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243558">(Nov 30 2019 at 15:35)</a>:</h4>
<p>I think it makes sense if you are very used to <code>!</code>,  but I'm fine not doing it unless it can be made less surprising for everything that isn't.</p>



<a name="182243598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243598">(Nov 30 2019 at 15:36)</a>:</h4>
<p>The big battle here is just getting <code>try_</code> methods on the collections at all</p>



<a name="182243606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243606">(Nov 30 2019 at 15:36)</a>:</h4>
<p>Yeah, it's a nice thing regarding <code>!</code>, but incompatible with <code>try_*</code>.</p>



<a name="182243619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243619">(Nov 30 2019 at 15:37)</a>:</h4>
<p>So without the <code>Error = !</code> bounds, I suspect people will push to drop the associated error type altogether?</p>



<a name="182243625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243625">(Nov 30 2019 at 15:37)</a>:</h4>
<p>However, <code>Error=!</code> as bound on <code>reserve</code> and other non-<code>try_</code> methods is just a way to force the user to use <code>try</code> instead.</p>



<a name="182243677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243677">(Nov 30 2019 at 15:38)</a>:</h4>
<p>Yes, it is nice to pass in a collection to a library that is allocator polymorphic, and force it to do the right thing</p>



<a name="182243678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243678">(Nov 30 2019 at 15:38)</a>:</h4>
<blockquote>
<p>So without the Error = ! bounds, I suspect people will push to drop the associated error type altogether?</p>
</blockquote>
<p>Yes, another thing I totally forgot: You would have need to wrap nearly all allocators in <code>AbortAlloc</code> to just ignore the associated error. Just as you mentioned, the ecosystem is split there.</p>



<a name="182243693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243693">(Nov 30 2019 at 15:39)</a>:</h4>
<p>It's a nice thing, if you <strong>want</strong> to never panic/abort. But that's only the unusual case.</p>



<a name="182243698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243698">(Nov 30 2019 at 15:39)</a>:</h4>
<p>Normal programs will never recover from OOM anyway.</p>



<a name="182243739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243739">(Nov 30 2019 at 15:40)</a>:</h4>
<p>We can still support both ecosystem with the approach on master today</p>



<a name="182243741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243741">(Nov 30 2019 at 15:40)</a>:</h4>
<p>And the capacity overflow panic is a bug in the program</p>



<a name="182243745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243745">(Nov 30 2019 at 15:40)</a>:</h4>
<p>Just you are really reliant on checking for master by hand</p>



<a name="182243755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243755">(Nov 30 2019 at 15:40)</a>:</h4>
<p>But I'll admit that any library should be able to do the <code>foo</code> <code>try_foo</code> duplication with the panic rather than <code>Error = !</code> bound</p>



<a name="182243764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243764">(Nov 30 2019 at 15:41)</a>:</h4>
<p>so the same libraries can support both still</p>



<a name="182243779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243779">(Nov 30 2019 at 15:41)</a>:</h4>
<p>Yeah I am much more sympathetic to capacity overflow always being a regular overflow panic</p>



<a name="182243783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243783">(Nov 30 2019 at 15:42)</a>:</h4>
<p>and well, if you don't want to panic run a model checker or something</p>



<a name="182243848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243848">(Nov 30 2019 at 15:42)</a>:</h4>
<p>as you shouldn't sanitize uncontrolled values by catching those errors, since as you say this program really is broken whereas normal allocation failure can be not the program's fault</p>



<a name="182243865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243865">(Nov 30 2019 at 15:43)</a>:</h4>
<p>Another Idea: I think we are able to support both ecosystems this way: ...</p>



<a name="182243877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243877">(Nov 30 2019 at 15:44)</a>:</h4>
<p>- Introduce a marker trait <code>Abort</code><br>
- for <code>reserve</code> and allocating non-<code>try_*</code> methods add this as bound<br>
- Implement <code>Abort</code> on <code>Global</code> and <code>System</code></p>



<a name="182243929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243929">(Nov 30 2019 at 15:44)</a>:</h4>
<p>That's basically the inversion of <code>AbortAlloc</code>, right?</p>



<a name="182243957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243957">(Nov 30 2019 at 15:45)</a>:</h4>
<p>And if you want to be forced to check OOM, you just have to wrap your allocator but don't implement <code>Abort</code></p>



<a name="182243961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243961">(Nov 30 2019 at 15:45)</a>:</h4>
<p>:)</p>



<a name="182243967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243967">(Nov 30 2019 at 15:45)</a>:</h4>
<p>That also removes the very missleading term of "infallible"</p>



<a name="182243977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182243977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182243977">(Nov 30 2019 at 15:45)</a>:</h4>
<p><code>Global</code> isn't infallible, we want to ignore the error</p>



<a name="182244005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244005">(Nov 30 2019 at 15:46)</a>:</h4>
<p><code>Abort</code> allows the allocator to fail</p>



<a name="182244033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244033">(Nov 30 2019 at 15:46)</a>:</h4>
<p>the one thing is it's the collection doing the panicking, not the allocator, right?</p>



<a name="182244036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244036">(Nov 30 2019 at 15:46)</a>:</h4>
<p>I think you want <code>Abort</code> and <code>AbortAlloc</code></p>



<a name="182244056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244056">(Nov 30 2019 at 15:47)</a>:</h4>
<p>Yes, I think so</p>
<p>Hmm, let's see. let me write a few lines of code...</p>



<a name="182244058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244058">(Nov 30 2019 at 15:47)</a>:</h4>
<p>if you have an <code>A: Abort</code> Then it does a cast to <code>AbortAlloc&lt;A&gt;</code> and calls the method with that?</p>



<a name="182244128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244128">(Nov 30 2019 at 15:49)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Abort</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">Abort</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Global</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span>: <span class="nc">DeallocRef</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">reserve</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">additional</span>: <span class="kt">usize</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="k">where</span><span class="w"></span>
<span class="w">        </span><span class="n">A</span>: <span class="nc">ReallocRef</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">Abort</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">match</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">try_reserve</span><span class="p">(</span><span class="n">additional</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="nb">Ok</span><span class="p">(</span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">(),</span><span class="w"></span>
<span class="w">            </span><span class="nb">Err</span><span class="p">(</span><span class="n">CollectionAllocErr</span>::<span class="n">CapacityOverflow</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">capacity_overflow</span><span class="p">(),</span><span class="w"></span>
<span class="w">            </span><span class="nb">Err</span><span class="p">(</span><span class="n">CollectionAllocErr</span>::<span class="n">AllocError</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">layout</span><span class="p">,</span><span class="w"> </span><span class="p">..</span><span class="w"> </span><span class="p">})</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">handle_alloc_error</span><span class="p">(</span><span class="n">layout</span><span class="p">.</span><span class="n">into</span><span class="p">()),</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">try_reserve</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">additional</span>: <span class="kt">usize</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="p">(),</span><span class="w"> </span><span class="n">CollectionAllocErr</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;&gt;</span><span class="w"></span>
<span class="w">    </span><span class="k">where</span><span class="w"></span>
<span class="w">        </span><span class="n">A</span>: <span class="nc">ReallocRef</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="n">buf</span><span class="p">.</span><span class="n">try_reserve</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">len</span><span class="p">,</span><span class="w"> </span><span class="n">additional</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="182244235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244235">(Nov 30 2019 at 15:51)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="c1">// Don&#39;t implement `Abort` on `SaveAlloc`</span>
<span class="k">struct</span> <span class="nc">SaveAlloc</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="p">(</span><span class="n">A</span><span class="p">);</span><span class="w"></span>

<span class="c1">// impl `AllocRef` etc. for `SaveAlloc`</span>
</pre></div>



<a name="182244240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244240">(Nov 30 2019 at 15:51)</a>:</h4>
<p>oh nice!</p>



<a name="182244245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244245">(Nov 30 2019 at 15:51)</a>:</h4>
<p>Yeah that's good, you can make a method that also requires <code>Abort</code> which calls <code>handle_alloc_error</code></p>



<a name="182244247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244247">(Nov 30 2019 at 15:52)</a>:</h4>
<p>Yeah, true! nice!</p>



<a name="182244290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244290">(Nov 30 2019 at 15:52)</a>:</h4>
<p>the <code>A</code> is sort of phantom as it takes an <code>Result&lt;T, A::Error&gt;</code></p>



<a name="182244296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244296">(Nov 30 2019 at 15:52)</a>:</h4>
<p>and another for <code>Result&lt;T, CollectionsError&lt;A::Error&gt;&gt;</code></p>



<a name="182244326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244326">(Nov 30 2019 at 15:53)</a>:</h4>
<p>Wow, I'm very excited, I think this is really a very good solution :)</p>



<a name="182244373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244373">(Nov 30 2019 at 15:54)</a>:</h4>
<p>me too! I was worried it would be endless type machinary, but this isn't even that bad!</p>



<a name="182244384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244384">(Nov 30 2019 at 15:54)</a>:</h4>
<p>It's just a single marker trait. We already got plenty marker traits anyway</p>



<a name="182244403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244403">(Nov 30 2019 at 15:55)</a>:</h4>
<p>yeah that's not a controversial thing by now</p>



<a name="182244407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244407">(Nov 30 2019 at 15:55)</a>:</h4>
<p>If you want to delegate to me to write it up, then you can get your time back with me rehashing the old AbortAlloc :)</p>



<a name="182244453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244453">(Nov 30 2019 at 15:56)</a>:</h4>
<p>I have to go now anyway. If you want to do this, go ahead!</p>



<a name="182244454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244454">(Nov 30 2019 at 15:56)</a>:</h4>
<p>I'll close your current PR then?</p>



<a name="182244476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244476">(Nov 30 2019 at 15:57)</a>:</h4>
<p>Yeah</p>



<a name="182244517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244517">(Nov 30 2019 at 15:58)</a>:</h4>
<p>Hey:</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Abort</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">T</span>: <span class="nc">AllocRef</span><span class="o">&lt;</span><span class="n">Error</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">!&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div>



<a name="182244522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244522">(Nov 30 2019 at 15:58)</a>:</h4>
<p>Yes can do that too, though will still need the separate <code>Global</code> and <code>System</code> ones</p>



<a name="182244526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gurwinder Singh <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244526">(Nov 30 2019 at 15:59)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="182244591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244591">(Nov 30 2019 at 16:00)</a>:</h4>
<blockquote>
<p>Yes can do that too, though will still need the separate <code>Global</code> and <code>System</code> ones</p>
</blockquote>
<p>Sure, but at least you don't have to implement <code>Abort</code> on any new allocators :)</p>



<a name="182244738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244738">(Nov 30 2019 at 16:04)</a>:</h4>
<p>Isn't this a good point to keep the associated error type?</p>



<a name="182244825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244825">(Nov 30 2019 at 16:06)</a>:</h4>
<p>Yes it is!</p>



<a name="182244832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244832">(Nov 30 2019 at 16:07)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> OK so first issue is I think we do need AbortAlloc with this, because in general don't have the <code>layout</code> for <code>handle_alloc_error</code></p>



<a name="182244837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244837">(Nov 30 2019 at 16:07)</a>:</h4>
<p>this is partially why the boxed ones still use <code>unwrap_unchecked</code>  by mistake</p>



<a name="182244841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244841">(Nov 30 2019 at 16:07)</a>:</h4>
<p>it's a lot less mechanical to fix</p>



<a name="182244842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182244842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182244842">(Nov 30 2019 at 16:07)</a>:</h4>
<p>but <code>AbortAlloc</code> can be private</p>



<a name="182245458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182245458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182245458">(Nov 30 2019 at 16:25)</a>:</h4>
<p>Yes, this would replace the <code>AbortAlloc</code> thing entirely.</p>
<p>I don't have more time today to head more into this, I'll look more into this tomorrow :)<br>
Just go ahead :)</p>



<a name="182247866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182247866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182247866">(Nov 30 2019 at 17:34)</a>:</h4>
<p>FWIW the <code>FallibleVec</code> would be what <code>Vec</code> is today</p>



<a name="182247871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182247871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182247871">(Nov 30 2019 at 17:34)</a>:</h4>
<p>and <code>Vec</code> would just become a "thin" wrapper over <code>FallibleVec</code> that "<code>.unwraps()</code>" (calls <code>handle_alloc_error</code>)  on every method</p>



<a name="182247946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182247946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182247946">(Nov 30 2019 at 17:36)</a>:</h4>
<p>There wouldn't be any <code>_try</code> methods</p>



<a name="182247953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182247953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182247953">(Nov 30 2019 at 17:36)</a>:</h4>
<p>You would just pick <code>Vec</code> or <code>FallibleVec</code> depending on whether you want an infallible or fallible API</p>



<a name="182248295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182248295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182248295">(Nov 30 2019 at 17:45)</a>:</h4>
<p>Yes, but it would introduce many many new structs</p>



<a name="182249333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182249333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182249333">(Nov 30 2019 at 18:10)</a>:</h4>
<blockquote>
<p>You would just pick <code>Vec</code> or <code>FallibleVec</code> depending on whether you want an infallible or fallible API</p>
</blockquote>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> beyond the many new structs, it would be much harder to reuse the implementation</p>



<a name="182249348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182249348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182249348">(Nov 30 2019 at 18:12)</a>:</h4>
<p><a href="https://github.com/TimDiekmann/alloc-wg/pull/16" target="_blank" title="https://github.com/TimDiekmann/alloc-wg/pull/16">https://github.com/TimDiekmann/alloc-wg/pull/16</a> is now up with <span class="user-mention" data-user-id="216785">@Tim Diekmann</span>'s <code>Abort</code> trait idea. I had to put in <code>AllocAbort</code> as an implementation detail, but a better method might be changing the error types to be something ~~ <code>(AllocError, NonZeroLayout)</code></p>



<a name="182249402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182249402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182249402">(Nov 30 2019 at 18:13)</a>:</h4>
<p>I say we try to get this one merged with the private <code>AllocAbort</code>, and then make another issue for the error handling, as the temporary <code>AllocAbort</code> is good to make the issue clear.</p>



<a name="182326746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182326746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182326746">(Dec 02 2019 at 09:17)</a>:</h4>
<p><span class="user-mention" data-user-id="220594">@John Ericson</span> by many new structs you mean, ~5 structs ? (Vec, List, HashMap, BTreeSet, Deque) ?</p>



<a name="182326755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182326755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182326755">(Dec 02 2019 at 09:17)</a>:</h4>
<p>Also, why do you think it would be harder to reuse the implementation ?</p>



<a name="182326769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182326769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182326769">(Dec 02 2019 at 09:17)</a>:</h4>
<p>You can reuse <code>Vec</code> like you do today, and for <code>FallibleVec</code> it would be just the same.</p>



<a name="182350837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182350837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182350837">(Dec 02 2019 at 14:37)</a>:</h4>
<p>At least those 5 structs + strings + any other structs that will be associated with an allocator.<br>
Additionally, every api addition has to be added to both structs, which is very error prone. Also, it's a huge documentation bloat. I don't see the advantages of <code>FallibleVec</code> in comparison to the <code>Abort</code> trait or the current solution.</p>



<a name="182350968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182350968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182350968">(Dec 02 2019 at 14:38)</a>:</h4>
<p><a href="https://github.com/rust-lang/wg-allocators/issues/7" target="_blank" title="https://github.com/rust-lang/wg-allocators/issues/7">Tracking Issue for structs which needs an allocator</a><br>
This would introduce at least 15(!) new structs for a rarely used API.</p>



<a name="182351378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182351378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182351378">(Dec 02 2019 at 14:43)</a>:</h4>
<p>Yeah those 15 types would be pretty much it</p>



<a name="182351452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182351452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182351452">(Dec 02 2019 at 14:44)</a>:</h4>
<p>Many API additions already need to be added to multiple types, e.g., to <code>Vec</code> and <code>RawVec</code>, particularly when they interact with allocators</p>



<a name="182351466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182351466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182351466">(Dec 02 2019 at 14:44)</a>:</h4>
<p>notice that this duplication of the API is only required for functions that could allocate</p>



<a name="182351480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182351480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182351480">(Dec 02 2019 at 14:44)</a>:</h4>
<p>so maybe there is a better way to land it than duplicating all structs</p>



<a name="182351541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182351541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182351541">(Dec 02 2019 at 14:45)</a>:</h4>
<p>I doubt that though, because while it is possible to write an infallible API on top of a fallible one, e.g., using a trait, you can't write a fallible API on top of an infallible one</p>



<a name="182351643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182351643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182351643">(Dec 02 2019 at 14:46)</a>:</h4>
<p>also, with a stable allocator interface, if somebody wants a fallible vector, they can just use one from <a href="http://crates.io" target="_blank" title="http://crates.io">crates.io</a></p>



<a name="182351736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182351736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182351736">(Dec 02 2019 at 14:47)</a>:</h4>
<p>doing that this way literally requires duplicating most of the code, but it can be done</p>



<a name="182353016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182353016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182353016">(Dec 02 2019 at 15:00)</a>:</h4>
<p>@gnzlbg I'm confused. There's now way to write arbitrary vec-polymorphic code without higher kinded types, so having multiple vecs seems like a disaster? What problems do you have with <a href="https://github.com/TimDiekmann/alloc-wg/pull/16" target="_blank" title="https://github.com/TimDiekmann/alloc-wg/pull/16">https://github.com/TimDiekmann/alloc-wg/pull/16</a> ?</p>



<a name="182353277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182353277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182353277">(Dec 02 2019 at 15:03)</a>:</h4>
<p>Also confused about the <a href="http://crates.io" target="_blank" title="http://crates.io">crates.io</a> bit. I agree it would be good if more collections came from crates.io—std can even have private deps and re-export. But this is totally  separate from allocator stuff? I.e. we should "pull a hash brown" for everything else anyways?</p>



<a name="182354941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182354941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182354941">(Dec 02 2019 at 15:18)</a>:</h4>
<blockquote>
<p>What problems do you have with <a href="https://github.com/TimDiekmann/alloc-wg/pull/16" target="_blank" title="https://github.com/TimDiekmann/alloc-wg/pull/16">https://github.com/TimDiekmann/alloc-wg/pull/16</a> ?</p>
</blockquote>
<p>If I'm writing a library that should propagate all alloaction errors to users, and my library uses an API like <code>Vec::extend</code>, how do I propagate the allocation error to a user such that it can recover ?</p>



<a name="182355251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182355251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182355251">(Dec 02 2019 at 15:21)</a>:</h4>
<blockquote>
<p>There's now way to write arbitrary vec-polymorphic code without higher kinded types, so having multiple vecs seems like a disaster?</p>
</blockquote>
<p>Why would you need that ?</p>



<a name="182355321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182355321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182355321">(Dec 02 2019 at 15:21)</a>:</h4>
<p>If you have an API that should accept / return multiple vector types, like <code>Vec</code>, <code>SmallVec</code>, or <code>ArrayVec</code>, then you can write a <code>VecLike</code> trait, and implement it for those types.</p>



<a name="182355377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182355377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182355377">(Dec 02 2019 at 15:22)</a>:</h4>
<p>I don't see how another kind of <code>Vec</code> makes this problem worse.</p>



<a name="182356732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182356732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182356732">(Dec 02 2019 at 15:33)</a>:</h4>
<blockquote>
<p>If I'm writing a library that should propagate all alloaction errors to users, and my library uses an API like <code>Vec::extend</code>, how do I propagate the allocation error to a user such that it can recover ?</p>
</blockquote>
<p>You write a <code>mylib::try_method</code> with <code>Vec::try_extend</code>, and then in the same manner make your <code>mylib::method</code> in terms of <code>mylib::try_method</code>.</p>



<a name="182356829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182356829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182356829">(Dec 02 2019 at 15:34)</a>:</h4>
<blockquote>
<p>I don't see how another kind of Vec makes this problem worse.</p>
</blockquote>
<p>I don't see how another kind of <code>Vec</code> makes this problem worse. It doesn't make the problem worse, but it's already bad. There's no good way to write <code>VecLike</code> today, and generic associated types only make that slightly better.</p>



<a name="182366178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182366178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182366178">(Dec 02 2019 at 17:05)</a>:</h4>
<p>I reviewed your PR <span class="user-mention" data-user-id="220594">@John Ericson</span>. Thanks again for implementing it :)</p>



<a name="182461186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182461186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182461186">(Dec 03 2019 at 15:41)</a>:</h4>
<p><span class="user-mention" data-user-id="220594">@John Ericson</span> </p>
<blockquote>
<p>You write a mylib::try_method with Vec::try_extend</p>
</blockquote>
<p>There is no <code>try_extend</code> method.</p>



<a name="182461208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182461208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182461208">(Dec 03 2019 at 15:41)</a>:</h4>
<p>And that approach would require duplicating most of the API of all collections</p>



<a name="182461286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182461286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182461286">(Dec 03 2019 at 15:42)</a>:</h4>
<p>I don't see how that is better than having two types providing the different APIs, and without the <code>try_</code> suffixes</p>



<a name="182461396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182461396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182461396">(Dec 03 2019 at 15:43)</a>:</h4>
<blockquote>
<p>It doesn't make the problem worse, but it's already bad. There's no good way to write VecLike today, and generic associated types only make that slightly better.</p>
</blockquote>
<p>I see that as an orthogonal issue. The argument that we should not do this because it would make something that's already impossible to do not harder isn't very strong.</p>



<a name="182948732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182948732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182948732">(Dec 09 2019 at 11:56)</a>:</h4>
<p>I actually tried out a <code>FallibleVec</code>. Besides my previous concerns, I also went into a no-go: You cannot trivially switch between a fallible and an aborting allocation, you have to know beforehand, if all OOMs aborts or return a <code>Result</code>.</p>



<a name="182948840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/182948840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#182948840">(Dec 09 2019 at 11:59)</a>:</h4>
<p>With the <code>Abort</code> marker trait, you can chose, if you allow aborting: you have to implement <code>Abort</code> for your allocator. If you don't implement it, the collection cannot abort. But if you do, you can chose, if your current allocation is allowed to abort or not.</p>



<a name="183361252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361252">(Dec 13 2019 at 14:03)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> i'm not sure i follow</p>



<a name="183361383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361383">(Dec 13 2019 at 14:05)</a>:</h4>
<p>With a <code>FallibleVec</code> if a call to an allocation function returns <code>ptr::null()</code> then you just propagate <code>Result::Err</code> up to the caller. The caller is then in charge of , if that <code>Result</code> is an error, calling <code>handle_alloc_error</code></p>



<a name="183361393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361393">(Dec 13 2019 at 14:05)</a>:</h4>
<p>e.g. that;s what a <code>Vec&lt;T&gt;</code> wrapper built on top of <code>FallibleVec&lt;T&gt;</code> would do</p>



<a name="183361421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361421">(Dec 13 2019 at 14:05)</a>:</h4>
<p>(this is in the current world where there is no <code>AllocRef</code> trait)</p>



<a name="183361502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361502">(Dec 13 2019 at 14:06)</a>:</h4>
<p>Which vector would you use, when you don't care about OOM in one place, but catch OOMs in another place?</p>



<a name="183361656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361656">(Dec 13 2019 at 14:08)</a>:</h4>
<p>When you don't care about OOM, you use <code>Vec&lt;T&gt;</code>, which calls <code>handle_alloc_error</code> on OOM</p>



<a name="183361675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361675">(Dec 13 2019 at 14:08)</a>:</h4>
<p>When you care about OOM you use <code>FallibleVec</code> which returns a <code>Result::Err</code> on OOM</p>



<a name="183361700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361700">(Dec 13 2019 at 14:09)</a>:</h4>
<p>Yeah, but you need two dedicated structs here<br>
You always have to know beforehand if you want to catch OOM or not</p>



<a name="183361706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361706">(Dec 13 2019 at 14:09)</a>:</h4>
<p>The layout of both vector types is identical, so if you need to handle OOM in certain situations, and not in others</p>



<a name="183361725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361725">(Dec 13 2019 at 14:09)</a>:</h4>
<p>you can just go from Vec -&gt; FallibleVec and from FallibleVec-&gt;Vec</p>



<a name="183361731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361731">(Dec 13 2019 at 14:09)</a>:</h4>
<p>its a noop</p>



<a name="183361797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361797">(Dec 13 2019 at 14:10)</a>:</h4>
<p>well sure, that's the point, allowing users that know before hand what they want what to do</p>



<a name="183361809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361809">(Dec 13 2019 at 14:10)</a>:</h4>
<p>Hmm, That's a pretty bad design IMO, as you probably want to store the vector in a struct</p>



<a name="183361813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361813">(Dec 13 2019 at 14:10)</a>:</h4>
<p>if you need a library that supports both, you can always just use FallibleVec</p>



<a name="183361824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361824">(Dec 13 2019 at 14:10)</a>:</h4>
<p>And call <code>handle_alloc_error</code> manually?</p>



<a name="183361837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361837">(Dec 13 2019 at 14:11)</a>:</h4>
<p>Or propagate the errors to the API of your library</p>



<a name="183361858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361858">(Dec 13 2019 at 14:11)</a>:</h4>
<p>if the final binary doesn't care about OOM, they can just choose a global allocator that does that for you to fail fast</p>



<a name="183361969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361969">(Dec 13 2019 at 14:12)</a>:</h4>
<blockquote>
<p>Hmm, That's a pretty bad design IMO, as you probably want to store the vector in a struct</p>
</blockquote>
<p>Maybe, you can just swap the Vec out, since that is a nop as well</p>



<a name="183361974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183361974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183361974">(Dec 13 2019 at 14:12)</a>:</h4>
<p>But i'm open to any better design that satisfies all the constraints</p>



<a name="183362010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362010">(Dec 13 2019 at 14:13)</a>:</h4>
<p>The current design supports all constraints :D</p>



<a name="183362021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362021">(Dec 13 2019 at 14:13)</a>:</h4>
<p>Then I didn't understood it, because <code>Vec::push</code> calls <code>handle_alloc_err</code></p>



<a name="183362031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362031">(Dec 13 2019 at 14:13)</a>:</h4>
<p>and that's a constraint that it doesn't satisfy AFAICT</p>



<a name="183362058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362058">(Dec 13 2019 at 14:14)</a>:</h4>
<p>Yeah, this is just like the current implementation does</p>



<a name="183362116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362116">(Dec 13 2019 at 14:14)</a>:</h4>
<p>Yeah, so I think a constraint is that every function that can trigger an OOM in any std collection should be recoverable</p>



<a name="183362125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362125">(Dec 13 2019 at 14:14)</a>:</h4>
<p>If you want to get the alloc-error on <code>push</code> you have to call <code>try_push</code></p>



<a name="183362138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362138">(Dec 13 2019 at 14:14)</a>:</h4>
<p>And I'd prefer not to have to learn which subset of these APIs are available via <code>try_</code> methods</p>



<a name="183362150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362150">(Dec 13 2019 at 14:14)</a>:</h4>
<p>but instead just be able to call the normal method and get a result</p>



<a name="183362170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362170">(Dec 13 2019 at 14:15)</a>:</h4>
<p>That's a good point</p>



<a name="183362180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362180">(Dec 13 2019 at 14:15)</a>:</h4>
<p>if you don't want to move the vector out of a struct, you can always have a <code>Vec::fallible_mut_ref(&amp;mut self) -&gt; &amp;mut FallibleVec</code></p>



<a name="183362185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362185">(Dec 13 2019 at 14:15)</a>:</h4>
<p>that provides fallible operations</p>



<a name="183362216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362216">(Dec 13 2019 at 14:16)</a>:</h4>
<p>because they have the exact same layout, you can safely transmute a &amp;Vec/&amp;mut Vec into a &amp;FallibleVec/&amp;mut FallibleVec in place</p>



<a name="183362251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362251">(Dec 13 2019 at 14:16)</a>:</h4>
<p>But then <code>Vec</code> and <code>FallibleVec</code> are not interchangable</p>



<a name="183362271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362271">(Dec 13 2019 at 14:16)</a>:</h4>
<p>as the signatures of the functions differ</p>



<a name="183362285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362285">(Dec 13 2019 at 14:16)</a>:</h4>
<p>that's the goal?</p>



<a name="183362299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362299">(Dec 13 2019 at 14:16)</a>:</h4>
<p>with one API, you don't get <code>Result</code>s returned, because you don't care</p>



<a name="183362300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362300">(Dec 13 2019 at 14:16)</a>:</h4>
<p>Yeah, but then it's pretty unflexible</p>



<a name="183362314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362314">(Dec 13 2019 at 14:16)</a>:</h4>
<p>and with the other, you get Results returned, because you do care</p>



<a name="183362326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362326">(Dec 13 2019 at 14:16)</a>:</h4>
<p>and you can choose whether you care or not</p>



<a name="183362337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362337">(Dec 13 2019 at 14:17)</a>:</h4>
<p>If you do care about OOM, you can just use an allocator, which does not support aborting</p>



<a name="183362360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362360">(Dec 13 2019 at 14:17)</a>:</h4>
<p>Whether to abort on OOM or not is not up to the allocator though</p>



<a name="183362366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362366">(Dec 13 2019 at 14:17)</a>:</h4>
<p>Then the compiler won't let you call <code>push</code></p>



<a name="183362404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362404">(Dec 13 2019 at 14:17)</a>:</h4>
<p>Then you have two types <code>Vec&lt;T, A&gt;</code>, and <code>Vec&lt;T, AbortA&gt;</code> and these types are not interchangeable AFAICT</p>



<a name="183362409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362409">(Dec 13 2019 at 14:17)</a>:</h4>
<p>Maybe we need a third opinion here :)</p>



<a name="183362470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362470">(Dec 13 2019 at 14:18)</a>:</h4>
<p>But you can call any methods on <code>Vec&lt;T, AbortA&gt;</code></p>



<a name="183362492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362492">(Dec 13 2019 at 14:18)</a>:</h4>
<p>Your option of not allowing calling <code>Vec::push</code> still has the drawback of requiring to duplicate the whole API with <code>try_</code> methods.</p>



<a name="183362540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362540">(Dec 13 2019 at 14:19)</a>:</h4>
<p>With your option you has to duplicate the whole vector, even the non-allocating functions</p>



<a name="183362557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362557">(Dec 13 2019 at 14:19)</a>:</h4>
<p>Sure, but users don't have to learn any new APIs</p>



<a name="183362567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362567">(Dec 13 2019 at 14:19)</a>:</h4>
<p>Duplicating the whole vector is cheap</p>



<a name="183362599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362599">(Dec 13 2019 at 14:19)</a>:</h4>
<p>Gbzlbg we can do something about the try thing long term</p>



<a name="183362659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362659">(Dec 13 2019 at 14:20)</a>:</h4>
<p>As in, its just a simple wrapper type <code>struct Vec&lt;T, A&gt;(FallibleVec&lt;T, A&gt;);</code> that exposes the same API as FallibleVec, but calling handle_alloc_error instead of returning Result</p>



<a name="183362660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362660">(Dec 13 2019 at 14:20)</a>:</h4>
<p>But it's a lot harder to merge two types that have impls in the wild long term</p>



<a name="183362727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362727">(Dec 13 2019 at 14:21)</a>:</h4>
<p>I think having the collections be infallible by default, but offering a way to get a fallible handle, is much more simpler for users, than duplicating the whole API with different function names.</p>



<a name="183362742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362742">(Dec 13 2019 at 14:21)</a>:</h4>
<p>its also more amenable for <code>macro!</code>s, since they don't have to, e.g., concatenate <code>try_</code> to identifiers</p>



<a name="183362832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362832">(Dec 13 2019 at 14:22)</a>:</h4>
<p>although that would be another option, e.g., <code>fallible!(foo.push())</code> gets expanded to <code>foo.try_push()</code></p>



<a name="183362880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362880">(Dec 13 2019 at 14:22)</a>:</h4>
<p>With the current way it's really easy to make foo and try_foo methods downstream</p>



<a name="183362888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362888">(Dec 13 2019 at 14:22)</a>:</h4>
<p>That's a big requirement for me</p>



<a name="183362912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183362912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183362912">(Dec 13 2019 at 14:23)</a>:</h4>
<p>So we can actually have an ecosystem that supports both</p>



<a name="183363016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363016">(Dec 13 2019 at 14:24)</a>:</h4>
<p>Two types create <em>so</em> much more friction</p>



<a name="183363025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363025">(Dec 13 2019 at 14:24)</a>:</h4>
<p>I don't think anyone is going to bother supporting both</p>



<a name="183363034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363034">(Dec 13 2019 at 14:24)</a>:</h4>
<p>And the whole thing is dead in the water</p>



<a name="183363270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363270">(Dec 13 2019 at 14:27)</a>:</h4>
<p>I don't understand the difference</p>



<a name="183363278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363278">(Dec 13 2019 at 14:27)</a>:</h4>
<p>Maybe you can try to explain it in a different way?</p>



<a name="183363382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363382">(Dec 13 2019 at 14:28)</a>:</h4>
<p>With my proposal, when you implement a collection, you make all methods fallible, and then generate a wrapper that just calls <code>handle_alloc_error</code>, you can probably auto-generate the infallible wrapper with a proc macro derive.</p>



<a name="183363432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363432">(Dec 13 2019 at 14:29)</a>:</h4>
<p>Since you can go from one type to the other, you don't have to support two types AFAICT.</p>



<a name="183363469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363469">(Dec 13 2019 at 14:29)</a>:</h4>
<p>Or at least, no more than having to support different kinds of collections.</p>



<a name="183363581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363581">(Dec 13 2019 at 14:30)</a>:</h4>
<p>I mean, if you have something like serde serialize, it is trivial to derive two implementation for the two vectors, such that one propagates oom errors and the otherone doesn't</p>



<a name="183363635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363635">(Dec 13 2019 at 14:31)</a>:</h4>
<p>If you only have a single <code>Vec</code> type with <code>Vec::try_</code> methods, you get a single <code>Deserialize</code> implementation, that's not going to use the <code>Vec::try_</code> methods.</p>



<a name="183363667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363667">(Dec 13 2019 at 14:31)</a>:</h4>
<p>and if you want to recover from a deserialization that fails due to OOM, you need to write a vector wrapper anyways</p>



<a name="183363812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363812">(Dec 13 2019 at 14:33)</a>:</h4>
<p>Say your type has public constructors and uses Vec</p>



<a name="183363828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363828">(Dec 13 2019 at 14:33)</a>:</h4>
<p>Say your type has methods that use Vec</p>



<a name="183363843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183363843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183363843">(Dec 13 2019 at 14:33)</a>:</h4>
<p>Now you can't use macro</p>



<a name="183364045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183364045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183364045">(Dec 13 2019 at 14:35)</a>:</h4>
<p>?</p>



<a name="183364123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183364123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183364123">(Dec 13 2019 at 14:36)</a>:</h4>
<p>If you have</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">v</span>: <span class="nc">FallibleVec</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">a</span>: <span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="c1">// you just:</span>
<span class="kd">let</span><span class="w"> </span><span class="n">v</span>: <span class="nc">FallibleVec</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">foo</span><span class="p">(</span><span class="n">v</span><span class="p">.</span><span class="n">infallible</span><span class="p">()).</span><span class="n">fallible</span><span class="p">();</span><span class="w"></span>
</pre></div>



<a name="183364205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183364205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183364205">(Dec 13 2019 at 14:37)</a>:</h4>
<p>where <code>FallibleVec::infallible(self) -&gt; Vec</code> and <code>Vec::fallible(self) -&gt; FallibleVec</code></p>



<a name="183364609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183364609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183364609">(Dec 13 2019 at 14:40)</a>:</h4>
<p>I don't think the macro can do that for arbitrary signatures with Vec</p>



<a name="183364763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183364763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183364763">(Dec 13 2019 at 14:40)</a>:</h4>
<p>Especially if the thing parameterized with a Vec is abstract</p>



<a name="183364891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183364891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183364891">(Dec 13 2019 at 14:42)</a>:</h4>
<p>You need something like Haskell's Coercible to do this</p>



<a name="183364898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183364898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183364898">(Dec 13 2019 at 14:42)</a>:</h4>
<p>Full stop</p>



<a name="183365992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183365992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183365992">(Dec 13 2019 at 14:54)</a>:</h4>
<p>I'm not sure what you mean with "the macro can do that"</p>



<a name="183366104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183366104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183366104">(Dec 13 2019 at 14:56)</a>:</h4>
<p>They are different types, if you need to go from one to another, you just call a conversion function.</p>



<a name="183366148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183366148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183366148">(Dec 13 2019 at 14:56)</a>:</h4>
<p><code>Into::into</code> would do</p>



<a name="183366168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183366168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183366168">(Dec 13 2019 at 14:56)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">v</span>: <span class="nc">FallibleVec</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">foo</span><span class="p">(</span><span class="n">v</span><span class="p">.</span><span class="n">into</span><span class="p">()).</span><span class="n">into</span><span class="p">();</span><span class="w"></span>
</pre></div>



<a name="183392507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183392507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183392507">(Dec 13 2019 at 19:37)</a>:</h4>
<p>I would favor always writing <code>try_foo</code> first and then also having <code>foo</code> that simply does <code>try_foo(arg).unwrap()</code> be available for however much of the stuff you think people would want to unwrap all the time (perhaps even 100% of it)</p>



<a name="183392616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183392616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183392616">(Dec 13 2019 at 19:38)</a>:</h4>
<p>actually in the case of this it would be more like <code>try_foo(arg).or_else(|_|handle_alloc_error())</code></p>



<a name="183392716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183392716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183392716">(Dec 13 2019 at 19:39)</a>:</h4>
<p>Default to infallible is just not robust in the same way that unwrapping every Result and Option isn't very robust</p>



<a name="183842131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842131">(Dec 19 2019 at 12:54)</a>:</h4>
<p>I'm not sure what you are arguing for or against</p>



<a name="183842148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842148">(Dec 19 2019 at 12:55)</a>:</h4>
<p>Are you suggesting that every liballoc method that alloactes should have a <code>try_</code> counterpart ?</p>



<a name="183842172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842172">(Dec 19 2019 at 12:55)</a>:</h4>
<p>Like <code>Vec::try_extend</code> ?</p>



<a name="183842295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842295">(Dec 19 2019 at 12:57)</a>:</h4>
<p>I find that handling allocation errors is already uncomfortable enough, adding also the burden of writing <code>try_{everything}</code> makes this worse, and it also makes it easier for "bugs" to be introduced by accidentally using a non-<code>try_</code> method when you shouldn't.</p>



<a name="183842440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842440">(Dec 19 2019 at 12:59)</a>:</h4>
<p>Currently you don't handle allocation errors in collection at all (besides <code>handle_alloc_error</code>, which defaults to abort and I never have seen anyone using it).<br>
Why this would it makes easier for bugs? It's not possible to use non-<code>try</code> methods on allocators, which are not allowed to abort</p>



<a name="183842452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842452">(Dec 19 2019 at 12:59)</a>:</h4>
<p><code>Vec::try_reserve</code> exists</p>



<a name="183842546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842546">(Dec 19 2019 at 13:00)</a>:</h4>
<p>If I have code that must not fail on OOM, and I use <code>try_</code> methods everywhere, and then somebody accidentally slips a non-<code>try_</code> call somewhere, that's a bug, potentially a very big one.</p>



<a name="183842556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842556">(Dec 19 2019 at 13:00)</a>:</h4>
<p>On the level of a security vulnerability</p>



<a name="183842571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842571">(Dec 19 2019 at 13:00)</a>:</h4>
<p>Then you use an allocator, which does not implement <code>Abort</code></p>



<a name="183842589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842589">(Dec 19 2019 at 13:01)</a>:</h4>
<p>And then the non-<code>try_</code> methods are not available ?</p>



<a name="183842594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842594">(Dec 19 2019 at 13:01)</a>:</h4>
<p>yup</p>



<a name="183842600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842600">(Dec 19 2019 at 13:01)</a>:</h4>
<p>So why do I have to type more ?</p>



<a name="183842612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842612">(Dec 19 2019 at 13:01)</a>:</h4>
<p>And why do I need a different allocator ?</p>



<a name="183842632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842632">(Dec 19 2019 at 13:01)</a>:</h4>
<p>Because you may want to use <code>try_</code> on collection, which are allowed to abort</p>



<a name="183842679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842679">(Dec 19 2019 at 13:02)</a>:</h4>
<p>How is handling OOM an allocator issue ?</p>



<a name="183842689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842689">(Dec 19 2019 at 13:02)</a>:</h4>
<p>An allocator reports whether OOM happen, but it isn't its job to handle it</p>



<a name="183842714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842714">(Dec 19 2019 at 13:02)</a>:</h4>
<p>I see, that using <code>try_</code> isn't the best thing. but it's still much better than duplicating every collection</p>



<a name="183842729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842729">(Dec 19 2019 at 13:03)</a>:</h4>
<p>You are not duplicating every collection</p>



<a name="183842733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842733">(Dec 19 2019 at 13:03)</a>:</h4>
<p>That claim is super misleading</p>



<a name="183842741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842741">(Dec 19 2019 at 13:03)</a>:</h4>
<p>You are providing a type safe thin wrapper that expresses an invariant at the type level</p>



<a name="183842751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842751">(Dec 19 2019 at 13:03)</a>:</h4>
<p>You are not duplicating all the code involved</p>



<a name="183842752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842752">(Dec 19 2019 at 13:03)</a>:</h4>
<p>However you have two nearly same collection</p>



<a name="183842815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842815">(Dec 19 2019 at 13:04)</a>:</h4>
<p>Additionally, the allocator isn't envolved in OOM handling. <code>Abort</code> is just a marker trait</p>



<a name="183842818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842818">(Dec 19 2019 at 13:04)</a>:</h4>
<p>No, you have two different _types_ exposing two different ways of modifying a collections owned data using a single API</p>



<a name="183842835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842835">(Dec 19 2019 at 13:04)</a>:</h4>
<p>So if I have an allocator, when should I implement Abort for it ?</p>



<a name="183842879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842879">(Dec 19 2019 at 13:05)</a>:</h4>
<p><code>Abort</code> is implemented for <code>Global</code>, <code>System</code> and every allocator, which are infallible</p>



<a name="183842888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842888">(Dec 19 2019 at 13:05)</a>:</h4>
<p>This isn't true</p>



<a name="183842894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842894">(Dec 19 2019 at 13:05)</a>:</h4>
<p>Since Global and System can return a <code>ptr::null</code> on allocations</p>



<a name="183842896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842896">(Dec 19 2019 at 13:05)</a>:</h4>
<p>and that means that the allocation failed</p>



<a name="183842914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842914">(Dec 19 2019 at 13:05)</a>:</h4>
<blockquote>
<p>Abort is implemented for <code>Global</code>, <code>System</code> <strong>and</strong> every allocator, which are infallible</p>
</blockquote>



<a name="183842973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842973">(Dec 19 2019 at 13:06)</a>:</h4>
<p>Sure but that isn't true, since Global and System are fallible</p>



<a name="183842976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842976">(Dec 19 2019 at 13:06)</a>:</h4>
<p>today</p>



<a name="183842977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842977">(Dec 19 2019 at 13:06)</a>:</h4>
<p>You marking allocators, which are allowed to abort</p>



<a name="183842987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842987">(Dec 19 2019 at 13:06)</a>:</h4>
<p><code>Abort</code> does not mean, the allocator is infallible</p>



<a name="183842991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183842991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183842991">(Dec 19 2019 at 13:06)</a>:</h4>
<blockquote>
<p>which are infallible</p>
</blockquote>



<a name="183843003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843003">(Dec 19 2019 at 13:06)</a>:</h4>
<p>So what does <code>Abort</code> mean ?</p>



<a name="183843005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843005">(Dec 19 2019 at 13:06)</a>:</h4>
<p>Otherwise it would be named <code>Infallible</code></p>



<a name="183843035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843035">(Dec 19 2019 at 13:07)</a>:</h4>
<blockquote>
<p>Marker trait to indicate that the allocator is allowed to abort on OOM.</p>
</blockquote>



<a name="183843095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843095">(Dec 19 2019 at 13:08)</a>:</h4>
<p>Allowed but not required</p>



<a name="183843099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843099">(Dec 19 2019 at 13:08)</a>:</h4>
<p>right?</p>



<a name="183843104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843104">(Dec 19 2019 at 13:08)</a>:</h4>
<p>Yes</p>



<a name="183843116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843116">(Dec 19 2019 at 13:08)</a>:</h4>
<p>So the allocator can still return a null pointer</p>



<a name="183843118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843118">(Dec 19 2019 at 13:08)</a>:</h4>
<p>yes</p>



<a name="183843125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843125">(Dec 19 2019 at 13:08)</a>:</h4>
<p>the collection handles the abortion then</p>



<a name="183843126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843126">(Dec 19 2019 at 13:08)</a>:</h4>
<p>And allocators that do not have the <code>Abort</code> marker trait can abort on OOM, right ?</p>



<a name="183843154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843154">(Dec 19 2019 at 13:09)</a>:</h4>
<p>It's a marker trait regarding handling the OOM, not regarding allocating</p>



<a name="183843179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843179">(Dec 19 2019 at 13:09)</a>:</h4>
<p>Can you be more clearer ?</p>



<a name="183843267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843267">(Dec 19 2019 at 13:10)</a>:</h4>
<p>Seems like you are suggesting that implementing <code>Abort</code> for allocators means that the allocator might abort on OOM, which is something that all allocators are allowed to do any ways, but that this trait should hint users of the allocator, that they should abort if the allocator returns an error, which is something that users of the allocators can already do without the trait.</p>



<a name="183843301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843301">(Dec 19 2019 at 13:11)</a>:</h4>
<p>If an allocator without <code>Abort</code> returns a null pointer, handle_alloc_error still can be called</p>



<a name="183843439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843439">(Dec 19 2019 at 13:13)</a>:</h4>
<p>Take the <code>Vec</code> method <code>reserve</code>, it's bound on <code>Abort</code>: </p>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">reserve</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">additional</span>: <span class="kt">usize</span><span class="p">)</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">ReallocRef</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">Abort</span><span class="p">;</span><span class="w"></span>
</pre></div>


<p>If you chose an allocator, which implements <code>Abort</code> you may call <code>Vec::reserve</code>. But you are still able to call `try_reserve:</p>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">try_reserve</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">additional</span>: <span class="kt">usize</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="p">(),</span><span class="w"> </span><span class="n">CollectionAllocErr</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">A</span>: <span class="nc">ReallocRef</span><span class="p">;</span><span class="w"></span>
</pre></div>



<a name="183843476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843476">(Dec 19 2019 at 13:13)</a>:</h4>
<p>That's the whole thing of the <code>Abort</code> trait</p>



<a name="183843484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843484">(Dec 19 2019 at 13:13)</a>:</h4>
<p>It feels very weird to use a trait on allocators to customize collections behavior</p>



<a name="183843505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843505">(Dec 19 2019 at 13:14)</a>:</h4>
<p>That's probably a good point</p>



<a name="183843549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843549">(Dec 19 2019 at 13:14)</a>:</h4>
<p>Like for <code>jemalloc</code>, should I implement abort or not ?</p>



<a name="183843557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843557">(Dec 19 2019 at 13:14)</a>:</h4>
<p>Depends on your needs</p>



<a name="183843558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843558">(Dec 19 2019 at 13:14)</a>:</h4>
<p>that's for the user of jemalloc to decide on every vector they use</p>



<a name="183843561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843561">(Dec 19 2019 at 13:14)</a>:</h4>
<p>not for the allocator to decide</p>



<a name="183843564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843564">(Dec 19 2019 at 13:14)</a>:</h4>
<p>But I see the point</p>



<a name="183843597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843597">(Dec 19 2019 at 13:15)</a>:</h4>
<p>What you want to express is whether a particular vector should abort on OOM, or return an error</p>



<a name="183843603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843603">(Dec 19 2019 at 13:15)</a>:</h4>
<p>and that's orthogonal to the allocator used</p>



<a name="183843616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843616">(Dec 19 2019 at 13:15)</a>:</h4>
<p>Right now, Vec::reserve just calls <code>try_reserve</code> and unwraps.</p>



<a name="183843673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843673">(Dec 19 2019 at 13:16)</a>:</h4>
<p>I'd rather just express the property as part of the vector type somehow</p>



<a name="183843700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843700">(Dec 19 2019 at 13:16)</a>:</h4>
<p>When you take <code>Jemalloc</code>, and  <code>JemallocAbort</code> (like jemalloc, but implementing Abort), and instantiate <code>Vec&lt;T, Jemalloc&gt;</code> and <code>Vec&lt;T, JemallocAbort&gt;</code> you are duplicating the collection</p>



<a name="183843706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843706">(Dec 19 2019 at 13:17)</a>:</h4>
<p>It's probably better to express it on the collection, but not in the way of have two very similar collection of each type in std</p>



<a name="183843726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843726">(Dec 19 2019 at 13:17)</a>:</h4>
<p>If we would just have collection traits...</p>



<a name="183843728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843728">(Dec 19 2019 at 13:17)</a>:</h4>
<blockquote>
<p>you are duplicating the collection</p>
</blockquote>
<p>As in, this will instantiate the collection twice.</p>



<a name="183843745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843745">(Dec 19 2019 at 13:18)</a>:</h4>
<p>Why would you need collection traits?</p>



<a name="183843802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843802">(Dec 19 2019 at 13:18)</a>:</h4>
<p>Then you could implement a generic wrapper around collections</p>



<a name="183843820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843820">(Dec 19 2019 at 13:18)</a>:</h4>
<p>If you had a <code>VecLike</code> trait, that has a <code>VecLike::reserve -&gt; ???</code>  method, what would the <code>???</code> be ?</p>



<a name="183843838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843838">(Dec 19 2019 at 13:18)</a>:</h4>
<p>well, true^^</p>



<a name="183843868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843868">(Dec 19 2019 at 13:19)</a>:</h4>
<p>I think the <code>FallibleVec + Vec</code> solution is straightforward</p>



<a name="183843886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843886">(Dec 19 2019 at 13:19)</a>:</h4>
<p>Sure, you need to write the same API twice, but that's straightforward to do, and to understand</p>



<a name="183843910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843910">(Dec 19 2019 at 13:19)</a>:</h4>
<p>And well you need to implement <code>Vec</code> on top of <code>FallibleVec</code>, but that's also kind of trivial</p>



<a name="183843985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183843985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183843985">(Dec 19 2019 at 13:20)</a>:</h4>
<p>It is more work than adding <code>try_</code> methods, cause you need to implement the traits for the vector, etc.</p>



<a name="183844023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844023">(Dec 19 2019 at 13:20)</a>:</h4>
<p>But from a user of the standard library, both APIs are the same, there is only one API to learn, etc.</p>



<a name="183844108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844108">(Dec 19 2019 at 13:21)</a>:</h4>
<p>An alternative might be a <code>Vec&lt;T, A, const ErrorOnOOM: bool = true&gt;</code> kind of thing</p>



<a name="183844168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844168">(Dec 19 2019 at 13:22)</a>:</h4>
<p>Where we change the return types of all methods depending on the value of the <code>bool</code>..</p>



<a name="183844249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844249">(Dec 19 2019 at 13:23)</a>:</h4>
<p>I like the const generics approach, but I wouldn't use a boolean here. An enum expresses it better, like </p>
<div class="codehilite"><pre><span></span><span class="k">enum</span> <span class="nc">OomBehavior</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Abort</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Error</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="183844306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844306">(Dec 19 2019 at 13:24)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">struct</span> <span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">ErrorOnOOM</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="o">&gt;</span><span class="p">(...);</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">     </span><span class="k">fn</span> <span class="nf">reserve</span><span class="p">(...)</span><span class="w"> </span>-&gt; <span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">handle_alloc_error</span><span class="p">...</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="kc">false</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">     </span><span class="k">fn</span> <span class="nf">reserve</span><span class="p">(...)</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="p">....</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="183844319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844319">(Dec 19 2019 at 13:24)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> the enum sounds like a better idea</p>



<a name="183844414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844414">(Dec 19 2019 at 13:25)</a>:</h4>
<p>I still don't know, if changing the return type is a good idea though</p>



<a name="183844478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844478">(Dec 19 2019 at 13:26)</a>:</h4>
<p>I suppose we don't even need const generics</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">ErrorBehavior</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">Error</span><span class="p">;</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">Abort</span><span class="p">;</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">ErrorBehavior</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Error</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">ErrorBehavior</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Abort</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">struct</span> <span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">E</span>: <span class="nc">ErrorBehavior</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Abort</span><span class="o">&gt;</span><span class="p">(...);</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">Abort</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="k">fn</span> <span class="nf">reserve</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">Error</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="k">fn</span> <span class="nf">reserve</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="p">(),</span><span class="w"> </span><span class="p">...</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="183844513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844513">(Dec 19 2019 at 13:27)</a>:</h4>
<p>Okay, but I'd go with this approach:</p>



<a name="183844556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844556">(Dec 19 2019 at 13:27)</a>:</h4>
<p>We can't change the return type for current behavior (would be a backward incompat change), and we want to be able to use <code>Result</code> for the non-standard case, so i'm not sure how else to handle it.</p>



<a name="183844634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844634">(Dec 19 2019 at 13:28)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">struct</span> <span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">E</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Abort</span><span class="o">&gt;</span><span class="p">(...);</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">E</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">E</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="k">fn</span> <span class="nf">try_reserve</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="p">(),</span><span class="w"> </span><span class="p">...</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">Abort</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="k">fn</span> <span class="nf">reserve</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="183844663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844663">(Dec 19 2019 at 13:29)</a>:</h4>
<p>However, const generics is more clear. The trait approach is a workaround</p>



<a name="183844962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844962">(Dec 19 2019 at 13:32)</a>:</h4>
<p>Sure, I agree.</p>



<a name="183844983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183844983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183844983">(Dec 19 2019 at 13:33)</a>:</h4>
<p>For prototyping purposes, we can get the trait approach working today. The const generics part, I'm not 100% sure if this already works</p>



<a name="183845086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845086">(Dec 19 2019 at 13:34)</a>:</h4>
<p>With my last approach, <code>Error</code> is a superset of <code>Abort</code>: when using <code>Abort</code>, you have more methods which can be used</p>



<a name="183845230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845230">(Dec 19 2019 at 13:37)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=99631852589832f4d8214729ab418803" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=99631852589832f4d8214729ab418803">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=99631852589832f4d8214729ab418803</a></p>



<a name="183845233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845233">(Dec 19 2019 at 13:37)</a>:</h4>
<p>This works!</p>



<a name="183845251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845251">(Dec 19 2019 at 13:37)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> yes, I don't know how I feel about that</p>



<a name="183845300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845300">(Dec 19 2019 at 13:38)</a>:</h4>
<p>I understand the idea behind the super set, i don't know if that's a better API than just choosing whether all methods should abort or report error</p>



<a name="183845335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845335">(Dec 19 2019 at 13:38)</a>:</h4>
<p>Typically, it is not that you only care for a single operation, which is what your approach allows</p>



<a name="183845385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845385">(Dec 19 2019 at 13:39)</a>:</h4>
<p>Yes, the const generic approach works, but it's not possible to pass a default argument.</p>



<a name="183845395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845395">(Dec 19 2019 at 13:39)</a>:</h4>
<p>Not yet</p>



<a name="183845400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845400">(Dec 19 2019 at 13:39)</a>:</h4>
<p>The feature isn't finished</p>



<a name="183845451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845451">(Dec 19 2019 at 13:40)</a>:</h4>
<p>Is it possible to do so for types on stable rust ?</p>



<a name="183845457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845457">(Dec 19 2019 at 13:40)</a>:</h4>
<p>IIRC that's a nightly only feature</p>



<a name="183845459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845459">(Dec 19 2019 at 13:40)</a>:</h4>
<p>Yes, as you suggested, a trait should fulfill the needs until landing</p>



<a name="183845468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845468">(Dec 19 2019 at 13:40)</a>:</h4>
<p>I think it is. At least, array implementations uses const generics</p>



<a name="183845502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845502">(Dec 19 2019 at 13:41)</a>:</h4>
<blockquote>
<p>I understand the idea behind the super set, i don't know if that's a better API than just choosing whether all methods should abort or report error</p>
</blockquote>
<p>I think it's more understandable, than changing the API</p>



<a name="183845568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845568">(Dec 19 2019 at 13:42)</a>:</h4>
<p>IMO it feels unnaturally, when a return type changes with another parameter</p>



<a name="183845585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845585">(Dec 19 2019 at 13:42)</a>:</h4>
<p>Which is why I think I still believe that making this two types might still be better</p>



<a name="183845600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845600">(Dec 19 2019 at 13:42)</a>:</h4>
<p>But I think it feels unnatural to me to have a different method for it</p>



<a name="183845622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845622">(Dec 19 2019 at 13:43)</a>:</h4>
<p>I'm already expressing that I want to handle errors manually at the type level</p>



<a name="183845632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845632">(Dec 19 2019 at 13:43)</a>:</h4>
<p>why do i then need to also use completely different method names ?</p>



<a name="183845714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845714">(Dec 19 2019 at 13:44)</a>:</h4>
<p>Fair point</p>
<p>The parameter type has still a huge advange: Only the allocating functions has to be duplicated</p>



<a name="183845728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845728">(Dec 19 2019 at 13:44)</a>:</h4>
<p>Yes, that's a pretty big advantage</p>



<a name="183845761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845761">(Dec 19 2019 at 13:45)</a>:</h4>
<p>Converting between <code>Vec&lt;_, _, Abort&gt;</code> and <code>Vec&lt;_, _, Error&gt;</code> is a noop. Do you have suitable method names?</p>



<a name="183845762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845762">(Dec 19 2019 at 13:45)</a>:</h4>
<p>One probably minor disadvantage is the order of the type parameters, if you want to change how the error type is handled, you need to specify an allocator</p>



<a name="183845778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845778">(Dec 19 2019 at 13:45)</a>:</h4>
<p>And if we were to change the order of the type parameters, then to specify a different allocator you'd need to specify how errors are handled</p>



<a name="183845788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845788">(Dec 19 2019 at 13:45)</a>:</h4>
<p>Yes, but this also applies to HashMap and the hasher</p>



<a name="183845834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845834">(Dec 19 2019 at 13:46)</a>:</h4>
<p>yes, I don't think this is a major issue, nor a problem worth solving</p>



<a name="183845841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845841">(Dec 19 2019 at 13:46)</a>:</h4>
<p>It's a problem I already didn't like in C++</p>



<a name="183845851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845851">(Dec 19 2019 at 13:46)</a>:</h4>
<p>But, yes, minor one</p>



<a name="183845862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845862">(Dec 19 2019 at 13:46)</a>:</h4>
<p>Yes, but the solution would be "named type parameters", and that has other problems</p>



<a name="183845880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845880">(Dec 19 2019 at 13:46)</a>:</h4>
<p>Either way, if we ever get a general solution to this problem, the Vec API would automatically benefit from it</p>



<a name="183845905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845905">(Dec 19 2019 at 13:47)</a>:</h4>
<p>Let's just not focus on this for now</p>



<a name="183845923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845923">(Dec 19 2019 at 13:47)</a>:</h4>
<p>So I think I like this approach more than the <code>Abort</code> approach, unless I'm missing more details about how <code>Abort</code> is supposed to work</p>



<a name="183845988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183845988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183845988">(Dec 19 2019 at 13:48)</a>:</h4>
<p>Other WGs have "summary documents", so maybe we could have a hackmd or similar with a summary of the different approaches, and pros and con, that we can keep updated ?</p>



<a name="183846025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846025">(Dec 19 2019 at 13:48)</a>:</h4>
<p>Our summary is <code>alloc-wg</code> I guess <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="183846050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846050">(Dec 19 2019 at 13:49)</a>:</h4>
<blockquote>
<p>So I think I like this approach more than the <code>Abort</code> approach, unless I'm missing more details about how <code>Abort</code> is supposed to work</p>
</blockquote>
<p>No, I think that's it</p>



<a name="183846141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846141">(Dec 19 2019 at 13:50)</a>:</h4>
<p>The main reason I think I prefer this approach is the separation of concerns</p>



<a name="183846162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846162">(Dec 19 2019 at 13:50)</a>:</h4>
<p>Allocators should just need to worry about allocating and deallocating memory, turns out this is already hard enough.</p>



<a name="183846178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846178">(Dec 19 2019 at 13:50)</a>:</h4>
<p>to summarize our todays discussion: </p>
<ul>
<li>OOM behavior should be expressed on the collection, not on the allocator</li>
<li>the <code>OomBevahior</code> approach is better, than implementing two distinct types, as most of the API isn't affected by allocators anyway</li>
</ul>



<a name="183846190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846190">(Dec 19 2019 at 13:51)</a>:</h4>
<p>Regarding the return type:</p>



<a name="183846217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846217">(Dec 19 2019 at 13:51)</a>:</h4>
<p>Yes, you are right, we are already expressing "I want to handle errors on this collection, give me the result"</p>



<a name="183846315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846315">(Dec 19 2019 at 13:52)</a>:</h4>
<blockquote>
<p>the OomBevahior approach is better, than implementing two distinct types, as most of the API isn't affected by allocators anyway</p>
</blockquote>
<p>It's better from the implementation point-of-view. It is ok-ish from the user point-of-view, except when they want to change the error behavior, and this requires them to also pass an allocator, but that's a minor inconvenience. The <code>FallibleVec + Vec</code> approach requires duplicating the whole API, but one API reuses the other.</p>



<a name="183846365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846365">(Dec 19 2019 at 13:53)</a>:</h4>
<p>One thing I'm not sure is, how to re-use <code>Vec::try_reserve</code> (Or the <code>Vec::reserve(...) -&gt; Result</code> version, from the infallible one with this approach.</p>



<a name="183846483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846483">(Dec 19 2019 at 13:54)</a>:</h4>
<p><code>try_reserve</code> isn't stabilized yet. I don't think I get your point</p>



<a name="183846613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846613">(Dec 19 2019 at 13:56)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=c18da87e5fc8691e18362451a4a59e05" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=c18da87e5fc8691e18362451a4a59e05">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=c18da87e5fc8691e18362451a4a59e05</a></p>



<a name="183846632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846632">(Dec 19 2019 at 13:56)</a>:</h4>
<p>THis works</p>



<a name="183846695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846695">(Dec 19 2019 at 13:56)</a>:</h4>
<p>I meant, that when implementing the <code>Vec&lt;T, A, Abort&gt;::reserve(&amp;mut self, N) -&gt; () { .... }</code> method, we want to call the <code>Vec&lt;T, A, Error&gt;::reserve(...) -&gt; Result</code> method, and "unwrap" (or call handle_alloc_error)</p>



<a name="183846708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846708">(Dec 19 2019 at 13:57)</a>:</h4>
<p>To reuse its implementation</p>



<a name="183846819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846819">(Dec 19 2019 at 13:58)</a>:</h4>
<p>This "solves" it, but it is not guaranteed to work:</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="n">OnOomError</span>::<span class="n">Abort</span><span class="p">}</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="k">fn</span> <span class="nf">fallible</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="n">OnOomError</span>::<span class="n">Error</span><span class="p">}</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">          </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">transmute</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">      </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="183846821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846821">(Dec 19 2019 at 13:58)</a>:</h4>
<p>Ah yes, your playground would have been my proposal there</p>



<a name="183846863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846863">(Dec 19 2019 at 13:58)</a>:</h4>
<p>The problem is that the layout of the two <code>repr(Rust)</code> types isn't necessarily the same</p>



<a name="183846887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846887">(Dec 19 2019 at 13:59)</a>:</h4>
<p>so the <code>&amp;mut Vec&lt;.., Abort&gt; -&gt; &amp;mut Vec&lt;..., Error&gt;</code> cast might be unsound</p>



<a name="183846934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183846934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183846934">(Dec 19 2019 at 14:00)</a>:</h4>
<p>The transmute is only safe if the layouts are the same</p>



<a name="183847005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847005">(Dec 19 2019 at 14:00)</a>:</h4>
<p>Ahhhhh! wait, i think there is a clause somewhere that says that 1-ZSTs do not affect layout</p>



<a name="183847015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847015">(Dec 19 2019 at 14:00)</a>:</h4>
<p>We have the <code>RawVec</code> struct underneath anyway</p>



<a name="183847036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847036">(Dec 19 2019 at 14:00)</a>:</h4>
<p>You could just call <code>try_reserve</code> and <code>reserve</code> on <code>RawVec</code> then</p>



<a name="183847056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847056">(Dec 19 2019 at 14:00)</a>:</h4>
<p>(deleted)</p>



<a name="183847079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847079">(Dec 19 2019 at 14:01)</a>:</h4>
<p><a href="https://github.com/rust-lang/unsafe-code-guidelines/blob/master/reference/src/layout/structs-and-tuples.md#structs-with-1-zst-fields" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/blob/master/reference/src/layout/structs-and-tuples.md#structs-with-1-zst-fields">https://github.com/rust-lang/unsafe-code-guidelines/blob/master/reference/src/layout/structs-and-tuples.md#structs-with-1-zst-fields</a></p>



<a name="183847090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847090">(Dec 19 2019 at 14:01)</a>:</h4>
<blockquote>
<p>For the purposes of struct layout 1-ZST fields are ignored.</p>
</blockquote>



<a name="183847133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847133">(Dec 19 2019 at 14:01)</a>:</h4>
<p><code>PhantomData&lt;T&gt;</code> is a 1-ZST</p>



<a name="183847217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847217">(Dec 19 2019 at 14:02)</a>:</h4>
<p>So this might be sound</p>



<a name="183847225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847225">(Dec 19 2019 at 14:02)</a>:</h4>
<p>You don't have <code>PhantomData&lt;T&gt;</code> in the real <code>Vec</code> implementation</p>



<a name="183847231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847231">(Dec 19 2019 at 14:02)</a>:</h4>
<p>Every allocation is backed by <code>RawVec</code></p>



<a name="183847235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847235">(Dec 19 2019 at 14:02)</a>:</h4>
<p>We would need to add it for the <code>OnOomError</code> type parameter</p>



<a name="183847241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847241">(Dec 19 2019 at 14:02)</a>:</h4>
<p>Because otherwise the generic parameter is unused</p>



<a name="183847338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847338">(Dec 19 2019 at 14:03)</a>:</h4>
<p>You just forward the error type from the <code>Alloc</code> implementation</p>



<a name="183847404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847404">(Dec 19 2019 at 14:04)</a>:</h4>
<p>No, I meant for the <code>OnOomError</code> type parameter</p>



<a name="183847412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847412">(Dec 19 2019 at 14:04)</a>:</h4>
<p>Ah, true</p>



<a name="183847416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847416">(Dec 19 2019 at 14:04)</a>:</h4>
<p>that's not passed to <code>RawVec</code>, or is used anywhere</p>



<a name="183847422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847422">(Dec 19 2019 at 14:04)</a>:</h4>
<p>So we need to "use" it</p>



<a name="183847450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847450">(Dec 19 2019 at 14:04)</a>:</h4>
<p>Thought your <code>PhantomData&lt;T&gt;</code> denotes the value type</p>



<a name="183847487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847487">(Dec 19 2019 at 14:05)</a>:</h4>
<p>Yeah sorry, that was a confusing way to put it</p>



<a name="183847516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847516">(Dec 19 2019 at 14:05)</a>:</h4>
<p>However, we don't have to worry about transmuting, as <code>RawVec</code> already has the logic implemented</p>



<a name="183847530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847530">(Dec 19 2019 at 14:06)</a>:</h4>
<p>Yeah true, but not for all methods</p>



<a name="183847633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847633">(Dec 19 2019 at 14:06)</a>:</h4>
<p>That is, for <code>reserve</code>, sure, we can call <code>RawVec</code>, but for other methods like <code>extend</code>, <code>insert</code>, <code>resize</code>, etc. it might make sense to re-use some of the logic of these methods</p>



<a name="183847782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847782">(Dec 19 2019 at 14:08)</a>:</h4>
<p>is <code>Foo(T, U)</code> guaranteed to be the same as <code>Bar(T, U)</code>?</p>



<a name="183847873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847873">(Dec 19 2019 at 14:09)</a>:</h4>
<p><a href="#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Guarantees.20about.20layout.20of.20generic.20aggregates/near/183847831" title="#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Guarantees.20about.20layout.20of.20generic.20aggregates/near/183847831">https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Guarantees.20about.20layout.20of.20generic.20aggregates/near/183847831</a></p>



<a name="183847886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847886">(Dec 19 2019 at 14:09)</a>:</h4>
<p>I've asked this in the UCGs, but in general no, that's not guaranteed.</p>



<a name="183847978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183847978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183847978">(Dec 19 2019 at 14:10)</a>:</h4>
<p>E.g. <code>rustc</code> is allowed to re-order the fields of <code>Foo</code> and <code>Bar</code> differently, e.g., using PGO data, to put the "hottest" field at the front, and improve cache usage and performance</p>



<a name="183848009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183848009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183848009">(Dec 19 2019 at 14:10)</a>:</h4>
<p>If you want more layout guarantees, you need to use, e.g., <code>repr(C)</code></p>



<a name="183848768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183848768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183848768">(Dec 19 2019 at 14:18)</a>:</h4>
<p>It would still be possible to implement the logic on a dedicated type</p>



<a name="183850324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183850324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183850324">(Dec 19 2019 at 14:35)</a>:</h4>
<p>Do you have a proper name for converting between those two types? Or should we just use <code>Into</code>, <code>AsRef</code>, and <code>AsMut</code>?</p>



<a name="183852966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183852966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183852966">(Dec 19 2019 at 15:01)</a>:</h4>
<p>We could do both.</p>



<a name="183852986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183852986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183852986">(Dec 19 2019 at 15:01)</a>:</h4>
<p>We can provide, e.g., <code>into()</code> to convert one into the other, taking ownership.</p>



<a name="183853123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Design%20of%20%60AbortAlloc%60%20not%20compatible%20with%20%60try_reserve%60/near/183853123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60.html#183853123">(Dec 19 2019 at 15:02)</a>:</h4>
<p>But we also could provide a <code>Vec::fallible(&amp;mut self) -&gt;&amp;mut FallibleVec</code> method to allow users to perform fallible operations in a scope, without having to call into twice (to go from Vec-&gt;FallibleVec-&gt;Vec), or without having to move the vector out of a struct, etc.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>